翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
モデルを作成したら、CreateEndpointConfig
を使用してエンドポイント設定を作成します。Amazon SageMaker AI ホスティングサービスは、この設定を使用してモデルをデプロイします。設定では、 で を使用して作成された 1 つ以上のモデルを特定しCreateModel
、Amazon SageMaker AI でプロビジョニングするリソースをデプロイします。AsyncInferenceConfig
オブジェクトを指定し、OutputConfig
に対する出力 Amazon S3 ロケーションを指定します。オプションで、予測結果に関する通知を送信する Amazon SNS トピックを指定できます。Amazon SNS トピックの詳細については、「Amazon 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
: (オプション) 推論リクエストが正常に終了した場合 (SuccessTopic
) または失敗した場合 (ErrorTopic
) に通知を投稿する SNS トピック。
AsyncInferenceConfig
フィールドの ClientConfig
に次のオプションの引数を指定することもできます。
MaxConcurrentInvocationsPerInstance
: (オプション) SageMaker AI クライアントからモデルコンテナに送信される同時リクエストの最大数。