使用docker服务多个张量流模型

问题描述 投票:6回答:3

已经见过this github问题和this 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

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

撰写文件

version: '3'

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

配置文件

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: {}
    }
  }
}
docker docker-compose dockerfile tensorflow-serving
3个回答
3
投票

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

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

4
投票

我在Windows上遇到git bash的this双斜线问题。

因此,我通过command中的docker-compose传递了@ KrisR89提到的参数。

新的docker-compose看起来像这样,并与提供的dockerfile一起使用:

version: '3'

services:
  serving:
    build: .
    image: testing-models
    container_name: tf
    command: --model_config_file=/config/config.conf

0
投票

错误是由于服务无法找到您的模型。

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

您的docker compose文件未在容器中装载您的模型文件。因此,Serving无法找到您的模型。我建议设置三个配置文件。

1 docker-compose.yml

2 .env

3 models.config

docker-compose.yml

将模型文件从主机安装到容器。我认为您可以做到这一点:

 version: "3"
  services:
        sv:
                image: tensorflow/serving:latest
                restart: unless-stopped
                ports:
                        - 8500:8500
                        - 8501:8501
                volumes:
                        - ${MODEL1_PATH}:/models/${MODEL1_NAME}
                        - ${MODEL2_PATH}:/models/${MODEL2_NAME}
                        - /home/deploy/dcp-file/tf_serving/models.config:/models/models.config
                command: --model_config_file=/models/models.config

.env:链接到docker-compose.yml。从该文件加载路径。

MODEL1_PATH=/home/notebooks/water_model
MODEL1_NAME=water_model
MODEL2_PATH=/home/notebooks/ice_model
MODEL2_NAME=ice_model

models.config

model_config_list: {
  config {
    name:  "water_model",
    base_path:  "/models/water_model",
    model_platform: "tensorflow",
    model_version_policy: {
        versions: 1588723537
        versions: 1588734567
    }
  },
  config {
    name:  "ice_model",
    base_path:  "/models/ice_model",
    model_platform: "tensorflow",
    model_version_policy: {
        versions: 1588799999
        versions: 1588788888
    }
  }
}

您可以看到此serving official document

© www.soinside.com 2019 - 2024. All rights reserved.