创建端点配置 - Amazon SageMaker

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

创建端点配置

拥有模型后,请使用 CreateEndpointConfig 创建端点配置。Amazon SageMaker 托管服务使用此配置来部署模型。在配置中,您可以标识使用和创建的一个或多个模型 CreateModel,以部署您希望 Amazon 预置 SageMaker 的资源。指定 AsyncInferenceConfig 对象并为 OutputConfig 提供输出 Amazon S3 位置。您可以选择指定用于发送预测结果通知的 Amazon SNS 主题。有关亚马逊SNS主题的更多信息,请参阅配置亚马逊SNS

以下示例演示了如何使用 AWS SDK for Python (Boto3)创建端点配置:

import datetime from time import gmtime, strftime # Create an endpoint config name. Here we create one based on the date # so it we can search endpoints based on creation time. endpoint_config_name = f"XGBoostEndpointConfig-{strftime('%Y-%m-%d-%H-%M-%S', gmtime())}" # The name of the model that you want to host. This is the name that you specified when creating the model. model_name='<The_name_of_your_model>' create_endpoint_config_response = sagemaker_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": "variant1", # The name of the production variant. "ModelName": model_name, "InstanceType": "ml.m5.xlarge", # 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": f"s3://{s3_bucket}/{bucket_prefix}/output" # (Optional) specify Amazon SNS topics "NotificationConfig": { "SuccessTopic": "arn:aws:sns:aws-region:account-id:topic-name", "ErrorTopic": "arn:aws:sns:aws-region:account-id:topic-name", } }, "ClientConfig": { # (Optional) Specify the max number of inflight invocations per instance # If no value is provided, Amazon SageMaker will choose an optimal value for you "MaxConcurrentInvocationsPerInstance": 4 } } ) print(f"Created EndpointConfig: {create_endpoint_config_response['EndpointConfigArn']}")

在上述示例中,您为 AsyncInferenceConfig 字段的 OutputConfig 指定以下键:

  • S3OutputPath:请求中没有提供位置时,将响应输出上传到的位置。

  • NotificationConfig:(可选)在推理请求成功()或推理请求失败(SuccessTopicErrorTopic)时向您发布通知SNS的主题。

您还可以在 AsyncInferenceConfig 字段中为 ClientConfig 指定以下可选参数:

  • MaxConcurrentInvocationsPerInstance:(可选) SageMaker 客户端向模型容器发送的最大并发请求数。