- Newest
- Most votes
- Most comments
To pass an S3 path as a parameter for the output location in an asynchronous inference call to a SageMaker model, you need to configure the AsyncInferenceConfig object when creating your endpoint configuration. This object allows you to specify where the results of your asynchronous inference will be stored.
When invoking the asynchronous endpoint, you'll use the InvokeEndpointAsync API. Here's how you can set it up:
- First, create an AsyncInferenceConfig object. In this object, you'll specify the S3 output path where you want the model's output to be saved. For example:
AsyncInferenceConfig={ "OutputConfig": { "S3OutputPath": "s3://your-bucket-name/your-output-prefix" } }
-
Use this AsyncInferenceConfig when creating your endpoint configuration.
-
When you're ready to invoke the endpoint, you'll use the InvokeEndpointAsync API. In this call, you don't directly pass the S3 output path as a parameter. Instead, SageMaker uses the output location you specified in the AsyncInferenceConfig when you created the endpoint.
-
The InvokeEndpointAsync call will return a response object. This response includes an 'OutputLocation' field, which contains the S3 URI where the output will be stored.
Here's a basic example of how you might invoke the endpoint:
response = sagemaker_runtime.invoke_endpoint_async( EndpointName='your-endpoint-name', InputLocation='s3://input-bucket/input-file', InferenceId=str(uuid.uuid4()), ContentType='your-content-type' )
output_location = response['OutputLocation']
Remember, the actual output will be stored in the S3 location you specified when creating the endpoint, not in the location returned by this call. The OutputLocation in the response just confirms where SageMaker will place the results.
By following these steps, you can ensure that your asynchronous inference results are saved to the S3 path you specified when setting up the endpoint.
Sources
Run computer vision inference on large videos with Amazon SageMaker asynchronous endpoints | AWS Machine Learning Blog
Asynchronous inference - Amazon SageMaker AI
Check prediction results - Amazon SageMaker AI
Relevant content
- AWS OFFICIALUpdated a month ago
I need to make different calls, and for each call, I need to specify a different path to save the model results.
Is this possible?