SageMaker PyTorch Hosting 1.6 只能使用名为model.pth的模型文件吗?

0

【以下的问题经过翻译处理】 嗨,SageMaker PyTorch Hosting 1.6 只与名为 model.pth 的艺术品一起工作吗? 我正在尝试使用 1.6 的这个示例(https://github.com/aws-samples/amazon-sagemaker-bert-classify-pytorch),但部署失败并显示错误消息:

FileNotFoundError: [Errno 2] No such file or directory: '/opt/ml/model/model.pth'

文档中没有提到这样的限制。

profile picture
专家
已提问 8 个月前30 查看次数
1 回答
0

【以下的回答经过翻译处理】 是的,从这个github的issue中可以看到:https://github.com/aws/sagemaker-pytorch-inference-toolkit/issues/86

在这个issue中指出,新的Pytorch 1.6镜像要求模型文件名为“model.pth”,并链接到相关代码,其中设置了此默认值:https://github.com/aws/sagemaker-pytorch-inference-toolkit/blob/9a6869e/src/sagemaker_pytorch_serving_container/torchserve.py#L121

该线程中还指出,用户已经成功地适应了他们的代码来使用Pytorch 1.6中的torchserve,通过将其更改为在名为“model.pth”的文件中保存他们的模型。一旦重命名,他们仍然可以使用自定义推断脚本通过定义自定义“model_fn”来加载其模型:https://github.com/data-science-on-aws/workshop/blob/374329adf15bf1810bfc4a9e73501ee5d3b4e0f5/09_deploy/wip/pytorch/code/inference.py

profile picture
专家
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则