下面是ECR容器中的predict.py。Sagemaker端点在重试10-12分钟后给出“状态:失败”输出。/ping和/invocations方法都可用
/opt/ml/code/predict.py
----------
logger = logging.getLogger()
logger.setLevel(logging.INFO)
classpath = <.pkl file>
model = pickle.load(open(classpath, "rb"))
app = flask.Flask(__name__)
print(app)
@app.route("/ping", methods=["GET"]
def ping():
"""Determine if the container is working and healthy."""
return flask.Response(response="Flask running", status=200, mimetype="application/json")
@app.route("/invocations", methods=["POST"])
""InferenceCode""
return flask.Response(response="Invocation Completed", status=200,
mimetype="application/json")
Below snippet was both added and removed , however I still have the endpoint in failed status
if __name__ == '__main__':
app.run(host='0.0.0.0',port=5000)
Error :
"The primary container for production variant <modelname> did not pass the ping health check. Please check CloudWatch logs for this endpoint."
Sagemaker endpoint Cloudwatch logs.
[INFO] Starting gunicorn 20.1.0
[INFO] Listening at: http://0.0.0.0:8000 (1)
[INFO] Using worker: sync
[INFO] Booting worker with pid: 11```
预测器文件用于测试模型是否加载到/ping中,以及是否可以在/invocations中执行推断。如果您已经在SageMaker上对模型进行了培训,则需要从/opt/ml目录加载模型,如下所示
该类帮助加载您的模型,然后我们可以在/ping中进行验证
在这里,SageMaker将测试您是否正确加载了模型。For/调用包括传递到模型预测功能中的任何数据格式的推理逻辑
确保如上所示设置或配置predictor.py,以便SageMaker能够正确理解/检索您的模型
我在AWS&;我的意见是我自己的
相关问题 更多 >
编程相关推荐