Amazon SageMaker多容器模型部署遭遇ParamValidationError问题求助
Got it, let's break down this error and fix it step by step! The core issue here is a misplaced parameter—you're trying to use InferenceExecutionConfig in the wrong API call.
Why the Error Happens
The error message clearly states that InferenceExecutionConfig isn't a valid parameter for sm_client.create_model(). That parameter belongs to the endpoint configuration step, not the model creation step. The Direct mode for multi-container inference is defined when you set up your endpoint config, not when you register the model itself.
Step-by-Step Fix
Correct the Create Model Call
First, remove theInferenceExecutionConfigparameter from yourcreate_model()code—this call only needs to define your containers and execution role:create_model_response = sm_client.create_model( ModelName="multi-container3", Containers=[pytorch_container, pytorch_container2], ExecutionRoleArn=role, )Add Inference Execution Mode to Endpoint Config
When you create your endpoint configuration, that's where you specify theDirectmode for multi-container execution:# Create endpoint config with Direct mode endpoint_config_response = sm_client.create_endpoint_config( EndpointConfigName="multi-container-endpoint-config", ProductionVariants=[ { "VariantName": "multi-container-variant", "ModelName": "multi-container3", # Match your model name here "InitialInstanceCount": 1, "InstanceType": "ml.m5.xlarge", # Use an instance type compatible with your model "InferenceExecutionConfig": {"Mode": "Direct"} } ] )
Additional Troubleshooting Tips
- Check Boto3 Version: Even though you're using the latest SageMaker, make sure your boto3 library is up to date (old versions might not support newer parameters). Run
pip show boto3to check, and update withpip install --upgrade boto3if needed. - Validate Container Definitions: Double-check that each container in your
Containerslist has valid values forImage(the correct SageMaker PyTorch inference image URI) andModelDataUrl(if you're loading model artifacts from S3). - Cross-Reference AWS Docs: Always confirm parameter locations with the official SageMaker API documentation to avoid mixing up parameters across different API calls.
内容的提问来源于stack exchange,提问作者Sazzad

