build.sh 2.0 KB
Newer Older
C
channings 已提交
1 2
# 是否使用GPU(即是否使用 CUDA)
WITH_GPU=OFF
3

4
# 是否使用MKL or openblas,TX2需要设置为OFF
C
channings 已提交
5
WITH_MKL=ON
6

C
channings 已提交
7
# 是否集成 TensorRT(仅WITH_GPU=ON 有效)
8
WITH_TENSORRT=OFF
9

10 11 12
# 是否使用2.0rc1预测库
USE_PADDLE_20RC1=OFF

13 14 15 16 17
# TensorRT 的include路径
TENSORRT_INC_DIR=/path/to/tensorrt/lib

# TensorRT 的lib路径
TENSORRT_LIB_DIR=/path/to/tensorrt/include
18

C
channings 已提交
19 20
# Paddle 预测库路径
PADDLE_DIR=/path/to/fluid_inference/
21

C
channings 已提交
22 23 24
# Paddle 的预测库是否使用静态库来编译
# 使用TensorRT时,Paddle的预测库通常为动态库
WITH_STATIC_LIB=OFF
25

C
channings 已提交
26
# CUDA 的 lib 路径
27
CUDA_LIB=/path/to/cuda/lib
28

C
channings 已提交
29
# CUDNN 的 lib 路径
30 31 32 33 34 35
CUDNN_LIB=/path/to/cudnn/lib


MACHINE_TYPE=`uname -m`
echo "MACHINE_TYPE: "${MACHINE_TYPE}

36

37 38 39
if [ "$MACHINE_TYPE" = "x86_64" ]
then
  echo "set OPENCV_DIR for x86_64"
40 41 42 43 44 45 46 47
  # linux系统通过以下命令下载预编译的opencv
  mkdir -p $(pwd)/deps && cd $(pwd)/deps
  wget -c https://bj.bcebos.com/paddleseg/deploy/opencv3.4.6gcc4.8ffmpeg.tar.gz2
  tar xvfj opencv3.4.6gcc4.8ffmpeg.tar.gz2 && cd ..

  # set OPENCV_DIR
  OPENCV_DIR=$(pwd)/deps/opencv3.4.6gcc4.8ffmpeg/

48 49 50
elif [ "$MACHINE_TYPE" = "aarch64" ]
then
  echo "set OPENCV_DIR for aarch64"
51 52 53 54 55 56 57 58
  # TX2平台通过以下命令下载预编译的opencv
  mkdir -p $(pwd)/deps && cd $(pwd)/deps
  wget -c https://paddlemodels.bj.bcebos.com/TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0.zip
  unzip TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0.zip && cd ..

  # set OPENCV_DIR
  OPENCV_DIR=$(pwd)/deps/TX2_JetPack4.3_opencv_3.4.10_gcc7.5.0/

59 60
else
  echo "Please set OPENCV_DIR manually"
61 62
fi

63
echo "OPENCV_DIR: "$OPENCV_DIR
64

C
channings 已提交
65
# 以下无需改动
66 67 68 69
rm -rf build
mkdir -p build
cd build
cmake .. \
C
channings 已提交
70 71 72
    -DWITH_GPU=${WITH_GPU} \
    -DWITH_MKL=${WITH_MKL} \
    -DWITH_TENSORRT=${WITH_TENSORRT} \
73 74
    -DTENSORRT_LIB_DIR=${TENSORRT_LIB_DIR} \
    -DTENSORRT_INC_DIR=${TENSORRT_INC_DIR} \
75
    -DPADDLE_DIR=${PADDLE_DIR} \
C
channings 已提交
76
    -DWITH_STATIC_LIB=${WITH_STATIC_LIB} \
77
    -DCUDA_LIB=${CUDA_LIB} \
C
channings 已提交
78 79
    -DCUDNN_LIB=${CUDNN_LIB} \
    -DOPENCV_DIR=${OPENCV_DIR}
80

81
make
82
echo "make finished!"