_build_py.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/bash
  2. set -e
  3. TRT_VERSION='8.5.2.2'
  4. CUDA_VERSION='11.8'
  5. CUDNN_VERSION='8.6'
  6. while [[ "$#" -gt 0 ]]; do
  7. case "$1" in
  8. --with-gpu) WITH_GPU="$2"; shift ;;
  9. --enable-benchmark) ENABLE_BENCHMARK="$2"; shift ;;
  10. --python) PYTHON_VERSION="$2"; shift ;;
  11. --paddleinference-url) PADDLEINFERENCE_URL="$2"; shift ;;
  12. --paddleinference-version) PADDLEINFERENCE_VERSION="$2"; shift ;;
  13. *) echo "Unknown parameter passed: $1"; exit 1 ;;
  14. esac
  15. shift
  16. done
  17. export DEBIAN_FRONTEND='noninteractive'
  18. export TZ='Asia/Shanghai'
  19. cd /workspace
  20. wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.tencent.com/repo/centos7_base.repo
  21. yum clean all
  22. yum makecache
  23. yum --disablerepo=epel -y update ca-certificates
  24. yum install -y wget bzip2
  25. yum install -y epel-release
  26. yum install -y patchelf rapidjson-devel
  27. PYTHON_DIR="/opt/_internal/cpython-${PYTHON_VERSION}"
  28. if [ -d "$PYTHON_DIR" ]; then
  29. ln -sf "${PYTHON_DIR}/bin/python${PYTHON_VERSION}" /usr/bin/python
  30. ln -sf "${PYTHON_DIR}/bin/pip${PYTHON_VERSION}" /usr/bin/pip
  31. export LD_LIBRARY_PATH="${PYTHON_DIR}/lib:${LD_LIBRARY_PATH}"
  32. export PATH="${PYTHON_DIR}/bin:${PATH}"
  33. else
  34. echo "Python version ${PYTHON_VERSION} not found in ${PYTHON_DIR}."
  35. exit 1
  36. fi
  37. python -m pip install numpy pandas
  38. cd /workspace/ultra-infer
  39. rm -rf "TensorRT-${TRT_VERSION}" "TensorRT-${TRT_VERSION}.Linux.x86_64-gnu.cuda-${CUDA_VERSION}.cudnn${CUDNN_VERSION}.tar.gz"
  40. http_proxy= https_proxy= wget "https://fastdeploy.bj.bcebos.com/resource/TensorRT/TensorRT-${TRT_VERSION}.Linux.x86_64-gnu.cuda-${CUDA_VERSION}.cudnn${CUDNN_VERSION}.tar.gz"
  41. tar -xzvf "TensorRT-${TRT_VERSION}.Linux.x86_64-gnu.cuda-${CUDA_VERSION}.cudnn${CUDNN_VERSION}.tar.gz"
  42. export WITH_GPU="${WITH_GPU}"
  43. export ENABLE_TRT_BACKEND="${WITH_GPU}"
  44. export TRT_DIRECTORY="/workspace/ultra-infer/TensorRT-${TRT_VERSION}"
  45. export ENABLE_ORT_BACKEND=ON
  46. export ENABLE_PADDLE_BACKEND=ON
  47. export PADDLEINFERENCE_URL="${PADDLEINFERENCE_URL}"
  48. export PADDLEINFERENCE_VERSION="${PADDLEINFERENCE_VERSION}"
  49. export ENABLE_OPENVINO_BACKEND=ON
  50. export ENABLE_VISION=ON
  51. export ENABLE_TEXT=ON
  52. export ENABLE_BENCHMARK="${ENABLE_BENCHMARK}"
  53. export CC=/usr/local/gcc-8.2/bin/gcc
  54. export CXX=/usr/local/gcc-8.2/bin/g++
  55. cd /workspace/ultra-infer/python
  56. python -m pip install wheel
  57. unset http_proxy https_proxy
  58. rm -rf .setuptools-cmake-build build ultra_infer/libs/third_libs dist
  59. python setup.py build
  60. # HACK
  61. patchelf \
  62. --set-rpath '$ORIGIN/libs/third_libs/onnxruntime/lib:$ORIGIN/libs/third_libs/paddle2onnx/lib:$ORIGIN/libs/third_libs/paddle_inference/paddle/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/cryptopp/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/mklml/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/glog/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/protobuf/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/utf8proc/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/xxhash/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/gflags/lib:$ORIGIN/libs/third_libs/paddle_inference/third_party/install/onednn/lib:$ORIGIN/libs/third_libs/tensorrt/lib:$ORIGIN/libs/third_libs/opencv/lib64:$ORIGIN/libs/third_libs/openvino/runtime/lib:$ORIGIN/libs/third_libs/openvino/runtime/3rdparty/omp/lib' \
  63. build/lib.*/ultra_infer/ultra_infer_main*.so
  64. python setup.py bdist_wheel