build.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # 是否使用GPU(即是否使用 CUDA)
  2. WITH_GPU=OFF
  3. # 是否使用MKL or openblas,TX2需要设置为OFF
  4. WITH_MKL=ON
  5. # 是否集成 TensorRT(仅WITH_GPU=ON 有效)
  6. WITH_TENSORRT=OFF
  7. # paddle 预测库lib名称,由于不同平台不同版本预测库lib名称不同,请查看所下载的预测库中`paddle_inference/lib/`文件夹下`lib`的名称
  8. PADDLE_LIB_NAME=libpaddle_inference
  9. # TensorRT 的include路径
  10. TENSORRT_INC_DIR=/path/to/tensorrt/include
  11. # TensorRT 的lib路径
  12. TENSORRT_LIB_DIR=/path/to/tensorrt/lib
  13. # Paddle 预测库路径
  14. PADDLE_DIR=/path/to/paddle_inference
  15. # CUDA 的 lib 路径
  16. CUDA_LIB=/path/to/cuda/lib
  17. # CUDNN 的 lib 路径
  18. CUDNN_LIB=/path/to/cudnn/lib
  19. MACHINE_TYPE=`uname -m`
  20. echo "MACHINE_TYPE: "${MACHINE_TYPE}
  21. if [ "$MACHINE_TYPE" = "x86_64" ]
  22. then
  23. echo "set OPENCV_DIR for x86_64"
  24. # linux系统通过以下命令下载预编译的opencv
  25. mkdir -p $(pwd)/deps && cd $(pwd)/deps
  26. wget -c https://paddledet.bj.bcebos.com/data/opencv3.4.6gcc8.2ffmpeg.zip
  27. unzip opencv3.4.6gcc8.2ffmpeg.zip && cd ..
  28. # set OPENCV_DIR
  29. OPENCV_DIR=$(pwd)/deps/opencv3.4.6gcc8.2ffmpeg
  30. elif [ "$MACHINE_TYPE" = "aarch64" ]
  31. then
  32. echo "set OPENCV_DIR for aarch64"
  33. # TX2平台通过以下命令下载预编译的opencv
  34. mkdir -p $(pwd)/deps && cd $(pwd)/deps
  35. wget -c https://paddlemodels.bj.bcebos.com/TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0.zip
  36. unzip TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0.zip && cd ..
  37. # set OPENCV_DIR
  38. OPENCV_DIR=$(pwd)/deps/TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0/
  39. else
  40. echo "Please set OPENCV_DIR manually"
  41. fi
  42. echo "OPENCV_DIR: "$OPENCV_DIR
  43. # 以下无需改动
  44. rm -rf build
  45. mkdir -p build
  46. cd build
  47. cmake .. \
  48. -DWITH_GPU=${WITH_GPU} \
  49. -DWITH_MKL=${WITH_MKL} \
  50. -DWITH_TENSORRT=${WITH_TENSORRT} \
  51. -DTENSORRT_LIB_DIR=${TENSORRT_LIB_DIR} \
  52. -DTENSORRT_INC_DIR=${TENSORRT_INC_DIR} \
  53. -DPADDLE_DIR=${PADDLE_DIR} \
  54. -DWITH_STATIC_LIB=${WITH_STATIC_LIB} \
  55. -DCUDA_LIB=${CUDA_LIB} \
  56. -DCUDNN_LIB=${CUDNN_LIB} \
  57. -DOPENCV_DIR=${OPENCV_DIR} \
  58. -DPADDLE_LIB_NAME=${PADDLE_LIB_NAME}
  59. make
  60. echo "make finished!"