在一个干净的docker环境(ubuntu16.04)中编译带 tensorrt 的 onnxruntime:
过程:
# 先 build 出 wheel
root@4ab06d738053:/tools/onnxruntime# ./build.sh \
--parallel 8 \
--use_cuda \
--cuda_version=11.1 \
--cuda_home=/usr/local/cuda \
--cudnn_home=/usr/local/cuda \
--use_tensorrt --tensorrt_home=/usr/local/lib/python3.8/dist-packages/tensorrt \
--build_shared_lib --enable_pybind \
--build_wheel --update --build \
--config Release
# 安装 wheel
root@4ab06d738053:/tools/onnxruntime# pip install build/Linux/Release/dist/onnxruntime_gpu_tensorrt-1.7.0-cp38-cp38-linux_x86_64.whl
# 查看结果,如果 import onnxruntime 有错误,要卸载 onnxruntime-gpu
root@4ab06d738053:/tools/onnxruntime# pip list | grep onnxruntime
onnxruntime-gpu 1.7.0
onnxruntime-gpu-tensorrt 1.7.0
出现的问题:
1、缺少 git 。
root@a42b2c92c7f3:/# git clone --recursive https://g