使用Docker服务多个Tensorflow模型

Que*_*ing 6 docker dockerfile docker-compose tensorflow-serving

看到这个 github问题和这个 stackoverflow帖子后,我希望这会简单地起作用。

似乎传递环境变量MODEL_CONFIG_FILE没有任何影响。我一直在运行,docker-compose但是使用却遇到了同样的问题docker-run


错误:

I tensorflow_serving/model_servers/server.cc:82] Building single TensorFlow model file config:  model_name: model model_base_path: /models/model
I tensorflow_serving/model_servers/server_core.cc:461] Adding/updating models.
I tensorflow_serving/model_servers/server_core.cc:558]  (Re-)adding model: model
E tensorflow_serving/sources/storage_path/file_system_storage_path_source.cc:369] FileSystemStoragePathSource encountered a file-system access error: Could not find base path /models/model for servable model
Run Code Online (Sandbox Code Playgroud)

Dockerfile

FROM tensorflow/serving:nightly

COPY ./models/first/ /models/first
COPY ./models/second/ /models/second

COPY ./config.conf /config/config.conf

ENV MODEL_CONFIG_FILE=/config/config.conf
Run Code Online (Sandbox Code Playgroud)

撰写文件

version: '3'

services:
  serving:
    build: .
    image: testing-models
    container_name: tf
Run Code Online (Sandbox Code Playgroud)

配置文件

model_config_list: {
  config: {
    name:  "first",
    base_path:  "/models/first",
    model_platform: "tensorflow",
    model_version_policy: {
        all: {}
    }
  },
  config: {
    name:  "second",
    base_path:  "/models/second",
    model_platform: "tensorflow",
    model_version_policy: {
        all: {}
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

Que*_*ing 7

我在 Windows 上遇到了 git bash这个双斜杠问题。

因此,我commanddocker-compose.

新的docker-compose看起来像这样并与提供的一起工作dockerfile

version: '3'

services:
  serving:
    build: .
    image: testing-models
    container_name: tf
    command: --model_config_file=/config/config.conf
Run Code Online (Sandbox Code Playgroud)


Kri*_*R89 6

没有名为“MODEL_CONFIG_FILE”的 docker 环境变量(这是一个 tensorflow/serving 变量,请参阅 docker 镜像链接),因此docker镜像将仅使用默认的 docker 环境变量(“MODEL_NAME=model”和“MODEL_BASE_PATH=/models”) ,并在 docker 镜像启动时运行模型“/models/model”。“config.conf”应该在“tensorflow/serving”启动时用作输入。尝试运行这样的东西:

docker run -p 8500:8500 8501:8501 \
  --mount type=bind,source=/path/to/models/first/,target=/models/first \
  --mount type=bind,source=/path/to/models/second/,target=/models/second \
  --mount type=bind,source=/path/to/config/config.conf,target=/config/config.conf\
  -t tensorflow/serving --model_config_file=/config/config.conf
Run Code Online (Sandbox Code Playgroud)

  • 虽然我很欣赏这个答案,但我特别需要它来通过 `docker-compose` 与 dockerfile 一起运行,dockerfile 将所有信息打包到一个图像中。我将在 github 问题上提出功能请求,看看是否可以实现。谢谢。 (3认同)