大型模型推理的 SageMaker 端点参数
您可以自定义以下参数,以协助使用 SageMaker 进行低延迟的大型模型推理 (LMI):
-
实例上的最大 Amazon EBS 卷大小 (
VolumeSizeInGB
) – 如果模型的大小大于 30 GB,并且您使用的实例没有本地磁盘,则应将此参数增加到略大于模型的大小。 -
运行状况检查超时限额 (
ContainerStartupHealthCheckTimeoutInSeconds
) – 如果您的容器设置正确,且 CloudWatch 日志指示运行状况检查超时,则应增加此限额,以便容器有足够的时间来响应运行状况检查。 -
模型下载超时限额 (
ModelDataDownloadTimeoutInSeconds
) – 如果您的模型大小大于 40 GB,则应增加此限额,以便有足够的时间将模型从 Amazon S3 下载到实例。
有关使用大型模型进行低延迟推理的更多信息,请参阅使用 DJL Serving 和 DeepSpeed 模型并行推理在 Amazon SageMaker 上部署大型模型斜体占位符文本
替换为您自己的信息。
import boto3 aws_region = "
aws-region
" sagemaker_client = boto3.client('sagemaker', region_name=aws_region) # The name of the endpoint. The name must be unique within an Amazon Region in your Amazon account. endpoint_name = "endpoint-name
" # Create an endpoint config name. endpoint_config_name = "endpoint-config-name
" # The name of the model that you want to host. model_name = "the-name-of-your-model
" instance_type = "instance-type
" sagemaker_client.create_endpoint_config( EndpointConfigName = endpoint_config_name ProductionVariants=[ { "VariantName": "variant1
", # The name of the production variant. "ModelName": model_name, "InstanceType": instance_type, # Specify the compute instance type. "InitialInstanceCount":1
, # Number of instances to launch initially. "VolumeSizeInGB":256
, # Specify the size of the Amazon EBS volume. "ModelDataDownloadTimeoutInSeconds":1800
, # Specify the model download timeout in seconds. "ContainerStartupHealthCheckTimeoutInSeconds":1800
, # Specify the health checkup timeout in seconds }, ], ) sagemaker_client.create_endpoint(EndpointName=endpoint_name, EndpointConfigName=endpoint_config_name)
有关 ProductionVariants
的键的更多信息,请参阅 ProductionVariant
和 创建端点配置。