提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
C++ pdserving 部署推理模型遇到的各种坑,通过这篇文章可以成功部署ppocrv3和ppocrv4版本,CPU和GPU版本,TensorRT版本
前言
踩了C++ pdserving部署paddleOCR v4/v3遇到的各种坑
升级完成之后感觉C++速度就是快!
使用的版本:pdServing 0.9版本
docker镜像:registry.baidubce.com/paddlepaddle/serving:0.9.0-cuda11.2-cudnn8-devel
一、安装各种相关包
```bash
python3.9 -m pip install -r python/requirements.txt -i -i https://pypi.tuna.tsinghua.edu.cn/simple
go env -w GO111MODULE=on
go env -w GOPROXY=https://goproxy.cn,direct
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
go install google.golang.org/grpc@v1.33.0
go env -w GO111MODULE=auto
二 、设置GPU环境变量
export CUDA_PATH='/usr/local/cuda'
export CUDNN_LIBRARY='/usr/lib/x86_64-linux-gnu/'
export CUDA_CUDART_LIBRARY="/usr/local/cuda-11.2/targets/x86_64-linux/lib/"
export TENSORRT_LIBRARY_PATH="/usr/"
三、关键步骤处理
1. serving下载
git clone https://github.com/PaddlePaddle/Serving
cd Serving && git submodule update --init --recursive
2. 更新环境
go install github.com/SunJary/dl/go1.18@latest // 安装下载程序
go1.19 download // 下载并安装
go1.19 version // 查看版本
详细情况请参考:https://zhuanlan.zhihu.com/p/482133602
3. 设置环境变量
export PYTHON_INCLUDE_DIR=/usr/local/include/python3.9/
export PYTHON_LIBRARIES=/usr/local/lib/libpython3.9.so
export PYTHON_EXECUTABLE=/usr/local/bin/python3.9
export GOPATH=/root/go1.9
export GOROOT=/root/sdk/go1.19
export PATH=/home/cmake-3.16.0-Linux-x86_64/bin:/usr/local/gcc-8.2/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/sdk/go1.19/bin:/root/go1.9/bin
修改PATH路径,去掉老的go版本路径, 添加新的路径
四、GPU编译
cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
-DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
-DCUDA_TOOLKIT_ROOT_DIR=${CUDA_