tensorflow-serving的docker方式同时加载多个模型

预备备:docker使用的是17.05.0-ce及以上的版本,之前用的13.XX的版本没有--mount这样的命令

0)下载安装tensorflow

#官网上抄的,啊哈哈

docker pull tensorflow/serving

git clone https://github.com/tensorflow/serving

1)创建一个多模型配置文件

#从tensorflow-serving git文档上抄下来的,啊哈哈

sudo vim {你的tf-serving配置文件根目录}/models.config

贴入以下内容

model_config_list: {

  config: {

    name: "half_plus_two",

    base_path: "/models/half_plus_two",

    model_platform: "tensorflow"

  },

  config: {

    name: "half_plus_three",

    base_path: "/models/half_plus_three",

    model_platform: "tensorflow"

  }

}

2)启动一个docker container

sudo docker run -p 8500:8500 -p 8501:8501 \

--mount type=bind,source={你的tf-serving根目录}/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_two_cpu,target=/models/half_plus_two\

--mount type=bind,source={你的tf-serving根目录}/serving/tensorflow_serving/servables/tensorflow/testdata/saved_model_half_plus_three,target=/models/half_plus_three\

--mount type=bind,source={你的tf-serving配置文件根目录}/models.config,target=/models/models.config \

-t tensorflow/serving --model_config_file=/models/models.config&

3)测试多个模型调用

curl -d '{"instances": [1.0, 2.0, 5.0]}' -X POST http://127.0.0.1:8501/v1/models/half_plus_two:predict

curl -d '{"instances": [1.0, 2.0, 5.0]}' -X POST http://127.0.0.1:8501/v1/models/half_plus_three:predict

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容