Knowledge Center Monthly Newsletter - March 2025
Stay up to date with the latest from the Knowledge Center. See all new and updated Knowledge Center articles published in the last month and re:Post’s top contributors.
我想对调用或创建 Amazon SageMaker AI 异步端点时出现的问题进行故障排除。
要检测调用异步端点时出现的错误,请查看该端点的 Amazon CloudWatch 日志。查看日志组(名称为 /aws/sagemaker/Endpoints/example-endpoint-name)和日志流(名称为 example-production-variant-name/example-instance-id/data-log)下的 CloudWatch 日志。有关详细信息,请参阅使用 CloudWatch 进行监控的“常用端点指标”部分和“异步推理端点指标”部分。
根据以下错误对调用或创建 SageMaker AI 异步端点时出现的问题进行故障排除:
如果在有效载荷大小小于 1 GB 时出现此错误,请查看异步端点的 CloudWatch 日志。此外,请使用不同大小的图像在本地测试模型,并确认有效载荷大小小于 1 GB 时是否会出现错误。
要在本地调试模型,请执行更多日志记录操作(打印语句),然后检查导致错误的代码部分。如果模型在本地运行时没有出现错误,请将模型托管在 SageMaker AI 上。有关详细信息,请参阅 GitHub 网站上的 amazon-sagemaker-local-mode。
示例代码:
import logging import syslogger = logging.getLogger(__name__) logger.setLevel(logging.DEBUG) logger.addHandler(logging.StreamHandler(sys.stdout)) logger.info("Loading file.")print("Loading file. --> from print statement")
当模型容器内没有足够的工作线程来处理 ping 和调用请求时,将会发生此错误。要解决此错误,请增加工作线程的数量和 model_server_timeout 值。
当无法有效清除队列请求时,将会出现此问题。SageMaker AI 异步端点使用先进先出 (FIFO) 方法。但是,模型推理时间、资源争用或网络延迟可能会干扰 FIFO 方法。
如果请求超时,请增加 InvocationTimeoutSeconds 参数的值。此参数指定在返回错误之前,SageMaker AI 等待进行推理的时间。您可以设置的最大值为 3600 秒(1 小时)。
此外,最佳做法是添加一个自动扩缩策略来监控 ApproximateBacklogSizePerInstance。这使您的端点能够根据待办事项大小进行纵向扩展,并加快请求的处理速度。
要解决此问题,请使用 AWS CLI 命令 describe-scalable-target、describe-scaling-policies 和 describe-scaling-activities。此外,请检查端点是否处于 InService 状态。
故障排除
How to get logs or print statements from SageMaker PyTorch deployed endpoint?
Configuring autoscaling inference endpoints in Amazon SageMaker
定义扩展策略
GitHub 网站上的 amazon-sagemaker-examples