AWSSageMaker端点失败。原因:生产变量AllTraffic的主容器未通过ping健康检查。
创始人
2024-09-27 01:30:20
0

一般来说,这种错误是由于模型部署所使用的主容器没有正确启动或者运行异常所导致的。为了解决这个问题,我们可以首先检查容器的日志信息,找出具体的错误信息。例如,在python中创建一个SageMaker的端点:

import sagemaker

# 创建SageMaker客户端
session = sagemaker.Session()
sm_client = session.boto_session.client('sagemaker')

# 指定模型的ARN
model_arn = 'arn:aws:sagemaker:us-east-1:123456789012:model/my-model'

# 创建端点配置
endpoint_config_name = 'my-endpoint-config'
endpoint_config = {
    'EndpointConfigName': endpoint_config_name,
    'ProductionVariants': [{
        'VariantName': 'AllTraffic',
        'ModelName': model_arn,
        'InitialInstanceCount': 1,
        'InstanceType': 'ml.t2.medium'
    }]
}
sm_client.create_endpoint_config(**endpoint_config)

# 创建端点
endpoint_name = 'my-endpoint'
endpoint = {
    'EndpointName': endpoint_name,
    'EndpointConfigName': endpoint_config_name
}
sm_client.create_endpoint(**endpoint)

# 等待端点创建完成
waiter = sm_client.get_waiter('endpoint_in_service')
waiter.wait(EndpointName=endpoint_name)

# 发送测试请求
from sagemaker.predictor import Predictor
predictor = Predictor(endpoint_name=endpoint_name)
predictor.predict('{"key": "value"}')

如果上述代码中,容器启动失败,我们就可以通过以下代码来获取容器的日志信息:

import re
import base64

logs = sm_client.describe_endpoint(EndpointName=endpoint_name)['EndpointConfig']['ProductionVariants'][0]['DeployedImages'][0]['Logs']
logs = base64.b64decode(logs).decode('utf-8')
error_messages = re.findall('.*(ERROR|Error|error):.*', logs)
for error_message in error_messages:

相关内容

热门资讯

外挂绝活儿!德扑圈透视,pok... 外挂绝活儿!德扑圈透视,pokernow辅助控制-好像是有辅助神器(哔哩哔哩)1、pokernow辅...
外挂机巧!哈糖大菠萝有挂吗,p... 外挂机巧!哈糖大菠萝有挂吗,pokeplus脚本-切实有辅助软件(哔哩哔哩)1、打开软件启动之后找到...
外挂秘籍!如何下载德普之星辅助... 外挂秘籍!如何下载德普之星辅助软件,大菠萝免费辅助-真是存在有辅助工具(哔哩哔哩)1、进入到大菠萝免...
外挂法子!pokerworld... 外挂法子!pokerworld辅助器,德普之星透视免费-真是是有辅助工具(哔哩哔哩)1、pokerw...
外挂讲义!德州透视竞技联盟,佛... 外挂讲义!德州透视竞技联盟,佛手大菠萝辅助-一贯是真的有辅助app(哔哩哔哩)1、该软件可以轻松地帮...
外挂妙招!菠萝德州透视脚本,哈... 外挂妙招!菠萝德州透视脚本,哈糖大菠萝有挂吗-好像一直总是有辅助软件(哔哩哔哩)1、该软件可以轻松地...
外挂练习!线上德州的辅助器是什... 外挂练习!线上德州的辅助器是什么,拱趴大菠萝辅助神器-一直一直都是有辅助软件(哔哩哔哩)1、起透看视...
外挂办法!大菠萝免费辅助器,p... 外挂办法!大菠萝免费辅助器,pokerrrr2辅助-切实是有辅助插件(哔哩哔哩)1、进入到大菠萝免费...
外挂讲义!拱趴游戏破解器,we... 外挂讲义!拱趴游戏破解器,werplan免费挂下载-总是是真的有辅助工具(哔哩哔哩)小薇(辅助器软件...
外挂妙招!线上德州的辅助器是什... 外挂妙招!线上德州的辅助器是什么,德州透视插件-都是有辅助插件(哔哩哔哩)1)线上德州的辅助器是什么...