如何在等待响应时增加AWS Sagemaker调用超时

问题描述

我向aws sagemaker部署了一个大型3D模型。推理将花费2分钟或更长时间。从Python调用预测变量时出现以下错误

An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (0) from model with message "Your invocation timed out while waiting for a response from container model. Review the latency metrics for each container in Amazon CloudWatch,resolve the issue,and try again."'

在Cloud Watch中,当容器正在处理时,我还看到一些PING超时:

2020-10-07T16:02:39.718+02:00 2020/10/07 14:02:39 https://forums.aws.amazon.com/ 106#106: *251 upstream timed out (110: Connection timed out) while reading response header from upstream,client: 10.32.0.2,server:,request: "GET /ping HTTP/1.1",upstream: "http://unix:/tmp/gunicorn.sock/ping",host: "model.aws.local:8080"

如何增加调用超时?

还是有一种方法可以对sagemaker端点进行异步调用

解决方法

当前无法增加超时-这是GitHub中的一个未解决问题。浏览有关SO的问题和类似问题,似乎您可以将批处理转换与推理结合使用。

参考

https://stackoverflow.com/a/55642675/806876

Sagemaker Python SDK超时问题:https://github.com/aws/sagemaker-python-sdk/issues/1119

,

此超时实际上是在服务器端-终结点上指定的。您可以尝试使用bring your own container也称为BYOC的方法,这样您就可以完全控制端点方的所有内容,包括超时。

您还可以引用此回购的终结点部分,该部分来自我的一位同事-https://github.com/jackie930/yolov4-SageMaker

您应更改的超时时间存在于serve.py model_server_timeout = os.environ.get('MODEL_SERVER_TIMEOUT',60)