如何在 Sagemaker 端点上运行推理?

问题描述 投票:0回答:0

我正在使用 AWS Sagemaker 和 Python 为机器学习模型部署端点,特别是在一组图像芯片上运行推理。但是,当我执行脚本来执行推理时,我收到一条错误消息,指出模型容器标头超过了指定的字节数。下面是我用来测试脚本和捕获的输出消息的示例图像(数组)。

import numpy as np
arr = np.ones([2,320,320,1], dtype=np.uint8)
      
from sagemaker.predictor import Predictor, numpy_deserializer, NumpySerializer, NumpyDeserializer
predictor = Predictor(endpoint_name_serialzer=NumpySerializer(), deserializer=NumpyDeserizlier())
result=predictor.predict(arr)
print(result.shape)

-> Error in <virtual_env>/python3.8/site-packages/sagemaker/predictory.py in line 161
response = self.sagemaker_session.sagemaker_runtime_client.invoke_endpoint(**request_args)
  
ModelError:  An error occurred (modelError) when calling the InvokeEndpoint operation: 
Received server error (O) from model with message "Response received from the model container 
has headers with length greater than 4096 bytes.  Reduce the length of your containers's 
response headers and update your endpoint  See https://us-iso-east- 
1.console.aws.amazon.com/cloudwatch/home?region=us-iso-east- 
1#logEventViewer:group=/aws/sagemaker/Endpoints/ModelTest-mdl-1 in account 12345679012"

我收到的错误发生在尝试对“result=predictor.predict(arr)”的端点使用预测函数时。我试图以其他方式找到 Sagemaker 模型容器标头的示例,但运气不佳......非常感谢任何帮助。

python amazon-web-services machine-learning amazon-sagemaker endpoint
© www.soinside.com 2019 - 2024. All rights reserved.