使用Docker服务多个Tensorflow模型 [英] Serving multiple tensorflow models using docker

查看:143
本文介绍了使用Docker服务多个Tensorflow模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

见过 github问题和 stackoverflow帖子,我曾希望这能正常工作。

Having seen this github issue and this stackoverflow post I had hoped this would simply work.

好像传入环境变量 MODEL_CONFIG_FILE 毫无影响。我通过 docker-compose 运行此程序,但使用 docker-run 遇到相同的问题。

It seems as though passing in the environment variable MODEL_CONFIG_FILE has no affect. I am running this through docker-compose but I get the same issue using 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






Dockerfile


The 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






撰写文件


The compose file

version: '3'

services:
  serving:
    build: .
    image: testing-models
    container_name: tf






配置文件


The config file

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: {}
    }
  }
}


推荐答案

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

There is no docker environment variable named "MODEL_CONFIG_FILE" (that’s a tensorflow/serving variable, see docker image link), so the docker image will only use the default docker environment variables ("MODEL_NAME=model" and "MODEL_BASE_PATH=/models"), and run the model "/models/model" at startup of the docker image. "config.conf" should be used as input at "tensorflow/serving" startup. Try to run something like this instead:

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

这篇关于使用Docker服务多个Tensorflow模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆