8501 — Rest Api 端口 8500 — gRPC 端口
CPU
sudo docker run -p 8501:8501 -p 8500:8500 –mount type=bind,source=/data/_models/n2n_xy,target=/models/n2n_xy -e MODEL_NAME=n2n_xy -t tensorflow/serving &
GPU
sudo docker run -p 8501:8501 -p 8500:8500 --mount type=bind,source=/data/_models/n2n_xy,target=/models/n2n_xy -e MODEL_NAME=n2n_xy -t tensorflow/serving:2.5.2-gpu &
sudo docker run --runtime=nvidia -p 8501:8501 -p 8500:8500 --mount type=bind,source=/data/_models/n2n_xy,target=/models/n2n_xy -e MODEL_NAME=n2n_xy -t tensorflow/serving:2.5.2-gpu &
测试 docker nvidia
sudo docker run --runtime=nvidia --rm nvidia/cuda:11.3.0-base-ubuntu18.04 nvidia-smi
nvidia-docker 安装与重载
sudo apt-get purge -y nvidia-docker sudo apt-get update
Install nvidia-docker2 and reload the Docker daemon configuration
sudo apt-get install -y nvidia-docker2 sudo pkill -SIGHUP dockerd
注: –runtime=nvidia 修改docker的Runtime为nvidia runtime工作
该选项非常重要,如果没有,tensorflow/serving:*-gpu 会使用 CPU 来运算
监控显卡
watch -n 2 nvidia-smi
|