推荐使用Docker内构建Paddle Serving,更多镜像请查看Docker镜像列表。当然仅仅想尝试学习部署的话,也可以部署对应环境后忽略docker相关操作进行部署paddleserving,Windows平台目前只支持用web service的方式搭建local predictor预测服务。
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo service docker stop
sudo service docker start
# docker服务启动后可以使用如下命令重启
sudo service docker restart
# nvidia-container-runtime-script.sh
sudo curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
sudo apt-key add -
distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
sudo curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \
sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
sudo apt-get update
sudo sh nvidia-container-runtime-script.sh
sudo apt-get update
sudo apt-get install nvidia-docker2
sudo apt-get install nvidia-container-runtime
# 验证
which nvidia-container-runtime
# 应当输出
/usr/bin/nvidia-container-runtime
装好以后就可以使用 nvidia-docker 或 docker run --gpus '“device=0”'命令
sudo groupadd docker
sudo usermod -aG docker ${USER}
sudo service docker restart
newgrp docker
docker ps
本地构建测试推荐使用devel镜像,实地部署推荐使用runtime镜像,最优方法是基于devel镜像的dockerfile自定义构建相关镜像
本例使用devel镜像示范
根据自身电脑配置选择是否使用GPU
# 启动 CPU Docker
docker pull registry.baidubce.com/paddlepaddle/serving:0.9.0-devel
docker run -p 9292:9292 --name test_cpu -dit registry.baidubce.com/paddlepaddle/serving:0.9.0-devel bash
docker exec -it test_cpu bash
git clone https://github.com/PaddlePaddle/Serving
# 启动 GPU Docker
docker pull registry.baidubce.com/paddlepaddle/serving:0.9.0-cuda11.2-cudnn8-devel
nvidia-docker run -p 9292:9292 --name test_gpu -dit registry.baidubce.com/paddlepaddle/serving:0.9.0-cuda11.2-cudnn8-devel bash
nvidia-docker exec -it test_gpu bash
git clone https://github.com/PaddlePaddle/Serving
cd Serving
pip3 install -r python/requirements.txt
pip3 install paddle-serving-client==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install paddle-serving-app==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
# CPU Server
pip3 install paddle-serving-server==0.9.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
# GPU Server,需要确认环境再选择执行哪一条,推荐使用CUDA 11.2的包
pip3 install paddle-serving-server-gpu==0.9.0.post112 -i https://pypi.tuna.tsinghua.edu.cn/simple
# CPU环境请执行
pip3 install paddlepaddle==2.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
# GPU CUDA 11.2环境请执行
pip3 install paddlepaddle-gpu==2.3.0.post112 -i https://pypi.tuna.tsinghua.edu.cn/simple
注意:paddlepaddle-gpu版本需要尽可能与cuda版本匹配,如遇到奇怪bug可以尝试降低版本
当以上步骤均完成后可使用命令行运行环境检查功能,自动运行Paddle Serving相关示例,进行环境相关配置校验。
python3 -m paddle_serving_server.serve check
命令 | 描述 |
---|---|
check_all | 检查 Paddle Inference、Pipeline Serving、C++ Serving。只打印检测结果,不记录日志 |
check_pipeline | 检查 Pipeline Serving,只打印检测结果,不记录日志 |
check_cpp | 检查 C++ Serving,只打印检测结果,不记录日志 |
check_inference | 检查 Paddle Inference 是否安装正确,只打印检测结果,不记录日志 |
debug | 发生报错后,该命令将打印提示日志到屏幕,并记录详细日志文件 |
exit | 退出 |
Install Docker Engine on Ubuntu
使用Docker安装Paddle Serving
Windows平台使用Paddle Serving指导
Paddle Serving 环境检查功能介绍