简体   繁体   English

Torchserve 在本地运行时无法在 docker 上加载 model

[英]Torchserve fails to load model on docker while it runs locally

I have a torchscript model ( .pt ) that I can successfully load and serve with torch serve on my local machine.我有一个 torchscript model ( .pt ),我可以在本地机器上成功加载和使用 torch serve 服务。 On the other side, when trying to deploy it in the oficial torchserve docker it will complain about the model and dont load it.另一方面,当尝试将其部署在官方的 torchserve docker 中时,它会抱怨 model 并且不加载它。

My local environment libraries are:我的本地环境库是:

  • torchserve version: 0.5.2火炬服务版本:0.5.2
  • torch-model-archiver version: 0.5.2火炬模型存档版本:0.5.2
  • torch version: 1.10火炬版本:1.10
  • java version: 17 java 版本:17
  • Operating System and version: MacOS 11.4操作系统和版本:MacOS 11.4

With Docker im using pytorch/torchserve:latest-cpu that I expect to have all versioning sorted out (i dont install specific versions).使用 Docker 即时通讯使用pytorch/torchserve:latest-cpu我希望所有版本都得到整理(我不安装特定版本)。

I would like to know if this is some bugs with the latest images or some missdoing from my side (and how to fix it).我想知道这是最新图像的一些错误还是我这边的一些失误(以及如何修复它)。 I will provide more details on environment and how to reproduce below.我将在下面提供有关环境以及如何重现的更多详细信息。

I have created a reproducible example in my repository, https://github.com/jiwidi/torchservebug .我在我的存储库https://github.com/jiwidi/torchservebug中创建了一个可重现的示例。 Clone it to reproduce it like this:克隆它以像这样复制它:

Run locally在本地运行

From the root folder run从根文件夹运行

$ sh test.sh

This runs successfully.这运行成功。

Run with docker与 docker 一起运行

From the root folder run从根文件夹运行

$ docker build . -t debug:v1

$ docker run debug:v1

This doesn't run, torchserve cant load the model and outputs java erros as well as some torch errors.这不运行,torchserve 无法加载 model 并输出 java 错误以及一些割炬错误。

Full failure log from docker can be found in this github issue https://github.com/pytorch/serve/issues/1402 docker 的完整故障日志可在此 github 问题https://github.com/pytorch/serve/issues/1402中找到

The first thing to know is that docker tags are just tags.首先要知道的是,docker 标签只是标签。 Just because it is tagged "latest" does not mean anything.仅仅因为它被标记为“最新”并不意味着什么。 In fact you will see that version 0.5.2-cpu is newer than latest-cpu here on dockerhub事实上,你会在 dockerhub 上看到0.5.2-cpu版本比latest-cpu 更新

Using this one at least gets rid of the java errors.使用这个至少可以消除 java 错误。 Other than that you should know that EXPOSE as a command in dockerfiles is confusing: It does absolutely nothing except serve as documentation.除此之外,您应该知道 EXPOSE 作为EXPOSE中的命令是令人困惑的:它除了作为文档之外什么都不做。 So if you need those ports to be accessible when you run the container you will have to publish the ports with the -p flag:因此,如果您需要在运行容器时访问这些端口,则必须使用-p标志发布端口:

docker run -p 8080:8080 -p 8081:8081 debug:v1

Hopefully that helps you on your way.希望这对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM