简体   繁体   English

如何将本地 model.mar 注册到正在运行的 torchserve 服务?

[英]How can I register a local model.mar to a running torchserve service?

I have a running torchserve service.我有一个正在运行的torchserve服务。 According to the docs, I can register a new model at port 8081 with the ManagementAPI .根据文档,我可以使用ManagementAPI在端口 8081 注册一个新的 model 。 When running curl -X OPTIONS http://localhost:8081 , the output also states for the post request on /models :运行curl -X OPTIONS http://localhost:8081时,output 还声明了/models上的 post 请求:

    ...
    "post": {
        "description": "Register a new model in TorchServe.",
        "operationId": "registerModel",
        "parameters": [
          {
            "in": "query",
            "name": "url",
            "description": "Model archive download url, support local file or HTTP(s) protocol. For S3, consider use pre-signed url.",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
     ...

Now, I do have a local model.mar file and want to use it with the file protocol.现在,我确实有一个本地 model.mar 文件,并希望将它与文件协议一起使用。 I tried:我试过了:

curl -X POST "http://localhost:8081/models?url=file:///path/to/model.mar"

But got:但得到:

{
  "code": 400,
  "type": "DownloadArchiveException",
  "message": "Failed to download archive from: file:///path/to/model.mar"
}

Is there anything that I am missing?有什么我想念的吗? How can I properly register a local model.mar to a running torchserve service?如何将本地model.mar正确注册到正在运行的torchserve服务?

I just figured it out.我刚刚想通了。 Everything I stated was completely correct and under normal circumstances, all of this would have worked.我所说的一切都是完全正确的,在正常情况下,所有这些都会奏效。

The error is arising because I am running the torchserve instance in a docker container and the curl command is sent to this container which then looks in his local files for the model.mar .出现错误是因为我在 docker 容器中运行torchserve实例,并且 curl 命令被发送到该容器,然后在他的本地文件中查找model.mar I thought for whatever reason that I can pass a file path from the machine that the docker container is running on.我认为无论出于何种原因,我都可以从运行 docker 容器的机器传递文件路径。
Instead, I have to copy the file into the docker container first (or mount a directory) and then execute the registering command with the file path from the model.mar inside the docker container.相反,我必须先将文件复制到 docker 容器中(或挂载目录),然后使用model.mar容器内 model.mar 的文件路径执行注册命令。

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

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