简体   繁体   English

如何通过docker容器正确安装TFServing

[英]How to correctly install TFServing via docker container

I have tried to install TFServing in docker container several times.我曾多次尝试在 docker 容器中安装 TFServing。 However I still can't build it without any error.但是,我仍然无法在没有任何错误的情况下构建它。
I follow the installation steps on the official site.我按照官方网站上的安装步骤进行操作。 But I still meet compile error during building.但是我在构建过程中仍然遇到编译错误。 I doubt that if there is some flaw in dockerfile which I built.我怀疑我构建的dockerfile是否存在一些缺陷。 I attach the screenshot of the error.我附上错误的截图。

As of now (Oct 2019), official docker image of TFServing for both CPU & GPU is available at https://hub.docker.com/r/tensorflow/serving .截至目前(2019 年 10 月),可在https://hub.docker.com/r/tensorflow/serving上获得用于 CPU 和 GPU 的 TFServing 官方 docker 映像。

To set up your tfserving image on docker, just pull the image & start the container.要在 docker 上设置您的 tfserving 镜像,只需拉取镜像并启动容器即可。

Pull the official image拉取官方镜像

docker pull tensorflow/serving:latest

Start the container启动容器

docker run -p 8500:8500 -p 8501:8501 --mount type=bind,source=/path/to/model/dir,target=/models/inception --name tfserve -e MODEL_NAME=inception -t tensorflow/serving:latest

For using GPU, pull GPU specific image and pass the appropriate parameters in docker command对于使用 GPU,拉取 GPU 特定图像并在 docker 命令中传递适当的参数

docker pull tensorflow/serving:latest-gpu

docker run -p 8500:8500 -p 8501:8501 --mount type=bind,source=/path/to/model/dir,target=/models/inception --name tfserve_gpu -e MODEL_NAME=inception --gpus all -t tensorflow/serving:latest-gpu --per_process_gpu_memory_fraction=0.001

Please note,请注意,

gpus all flag is used to allocate all available GPUs ( in case you have multiple in your machine ) to the docker container. gpus all标志用于将所有可用的 GPU(如果您的机器中有多个)分配给gpus all容器。

User gpus device=1 to select first GPU device, if you need to restrict usage to a particular device.用户gpus device=1选择第一个 GPU 设备,如果您需要限制使用特定设备。

per_process_gpu_memory_fraction flag is used to restrict GPU memory usage by the tfserving docker image. per_process_gpu_memory_fraction标志用于限制 tfserving docker 图像对 GPU 内存的使用。 Pass its value according to your program need.根据您的程序需要传递其值。

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

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