Skip to content

Instantly share code, notes, and snippets.

@gleeb
Last active August 11, 2022 11:12
Show Gist options
  • Save gleeb/1946bca4806ffbecd12fcac2a88f7a40 to your computer and use it in GitHub Desktop.
Save gleeb/1946bca4806ffbecd12fcac2a88f7a40 to your computer and use it in GitHub Desktop.
sagemaker deploy async endpoint
import boto3
sm_client = boto3.client('sagemaker', region_name='us-east-1')
endpoint_config_name = 'titanic-survival-async-endpoint-config'
print(endpoint_config_name)
create_endpoint_config_response = sm_client.create_endpoint_config(
EndpointConfigName=endpoint_config_name, # You will specify this name in a CreateEndpoint request.
# List of ProductionVariant objects, one for each model that you want to host at this endpoint.
ProductionVariants=[
{
"VariantName": "AllTraffic", # The name of the production variant.
"ModelName": 'titanic-survival-v1',
"InstanceType": "ml.m5.2xlarge", # Specify the compute instance type.
"InitialInstanceCount": 1 # Number of instances to launch initially.
}
],
AsyncInferenceConfig={
"OutputConfig": {
# Location to upload response outputs when no location is provided in the request.
"S3OutputPath": "s3://<your bucket>/sagemaker-async-out",
# (Optional) specify Amazon SNS topics
"NotificationConfig": {
"SuccessTopic": "<sns topic arn>",
"ErrorTopic": "<sns topic arn>",
}
},
"ClientConfig": {
"MaxConcurrentInvocationsPerInstance": 1 #increase this value upto throughput peak for best performance
}
}
)
endpoint_name = 'titanic-survival-async-endpoint'
print("EndpointName={}".format(endpoint_name))
create_endpoint_response = sm_client.create_endpoint(
EndpointName=endpoint_name,
EndpointConfigName=endpoint_config_name)
print(create_endpoint_response['EndpointArn'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment