build_server.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #使用镜像:
  2. #registry.baidubce.com/paddlepaddle/paddle:latest-dev-cuda10.1-cudnn7-gcc82
  3. #编译Serving Server:
  4. #client和app可以直接使用release版本
  5. #server因为加入了自定义OP,需要重新编译
  6. apt-get update
  7. apt install -y libcurl4-openssl-dev libbz2-dev
  8. wget https://paddle-serving.bj.bcebos.com/others/centos_ssl.tar && tar xf centos_ssl.tar && rm -rf centos_ssl.tar && mv libcrypto.so.1.0.2k /usr/lib/libcrypto.so.1.0.2k && mv libssl.so.1.0.2k /usr/lib/libssl.so.1.0.2k && ln -sf /usr/lib/libcrypto.so.1.0.2k /usr/lib/libcrypto.so.10 && ln -sf /usr/lib/libssl.so.1.0.2k /usr/lib/libssl.so.10 && ln -sf /usr/lib/libcrypto.so.10 /usr/lib/libcrypto.so && ln -sf /usr/lib/libssl.so.10 /usr/lib/libssl.so
  9. # 安装go依赖
  10. rm -rf /usr/local/go
  11. wget -qO- https://paddle-ci.cdn.bcebos.com/go1.17.2.linux-amd64.tar.gz | tar -xz -C /usr/local
  12. export GOROOT=/usr/local/go
  13. export GOPATH=/root/gopath
  14. export PATH=$PATH:$GOPATH/bin:$GOROOT/bin
  15. go env -w GO111MODULE=on
  16. go env -w GOPROXY=https://goproxy.cn,direct
  17. go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@v1.15.2
  18. go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger@v1.15.2
  19. go install github.com/golang/protobuf/protoc-gen-go@v1.4.3
  20. go install google.golang.org/grpc@v1.33.0
  21. go env -w GO111MODULE=auto
  22. # 下载opencv库
  23. wget https://paddle-qa.bj.bcebos.com/PaddleServing/opencv3.tar.gz && tar -xvf opencv3.tar.gz && rm -rf opencv3.tar.gz
  24. export OPENCV_DIR=$PWD/opencv3
  25. # clone Serving
  26. git clone https://github.com/PaddlePaddle/Serving.git -b develop --depth=1
  27. cd Serving
  28. export Serving_repo_path=$PWD
  29. git submodule update --init --recursive
  30. python -m pip install -r python/requirements.txt
  31. export PYTHON_INCLUDE_DIR=$(python -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())")
  32. export PYTHON_LIBRARIES=$(python -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
  33. export PYTHON_EXECUTABLE=`which python`
  34. export CUDA_PATH='/usr/local/cuda'
  35. export CUDNN_LIBRARY='/usr/local/cuda/lib64/'
  36. export CUDA_CUDART_LIBRARY='/usr/local/cuda/lib64/'
  37. export TENSORRT_LIBRARY_PATH='/usr/local/TensorRT6-cuda10.1-cudnn7/targets/x86_64-linux-gnu/'
  38. # cp 自定义OP代码
  39. cp -rf ../deploy/pdserving/general_detection_op.cpp ${Serving_repo_path}/core/general-server/op
  40. # 编译Server, export SERVING_BIN
  41. mkdir server-build-gpu-opencv && cd server-build-gpu-opencv
  42. cmake -DPYTHON_INCLUDE_DIR=$PYTHON_INCLUDE_DIR \
  43. -DPYTHON_LIBRARIES=$PYTHON_LIBRARIES \
  44. -DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
  45. -DCUDA_TOOLKIT_ROOT_DIR=${CUDA_PATH} \
  46. -DCUDNN_LIBRARY=${CUDNN_LIBRARY} \
  47. -DCUDA_CUDART_LIBRARY=${CUDA_CUDART_LIBRARY} \
  48. -DTENSORRT_ROOT=${TENSORRT_LIBRARY_PATH} \
  49. -DOPENCV_DIR=${OPENCV_DIR} \
  50. -DWITH_OPENCV=ON \
  51. -DSERVER=ON \
  52. -DWITH_GPU=ON ..
  53. make -j32
  54. python -m pip install python/dist/paddle*
  55. export SERVING_BIN=$PWD/core/general-server/serving
  56. cd ../../