在Jetson等设备上为不同版本的Python打包安装TensorRT

Jetson的TensoRT是板载、对应固定的Python版本的,如果手动安装了不同版本的Python,很难手动安装对应版本的TensorRT。

在这里提供一种方法,利用已有的TensorRT动态库和pybind11,根据Python版本需求制作安装包:

export EXT_PATH=/tmp/tensorrt-bindings
rm -rf $EXT_PATH
mkdir $EXT_PATH
cd $EXT_PATH

git clone https://github.com/pybind/pybind11.git
cd pybind11
git checkout v2.6.2
cd $EXT_PATH

wget https://www.python.org/ftp/python/3.8.13/Python-3.8.13.tgz
tar xvzf Python-3.8.13.tgz
mkdir python3.8
cp -r Python-3.8.13/Include/ python3.8/include
cp /usr/include/aarch64-linux-gnu/python3.8/pyconfig.h python3.8/include/

git clone https://github.com/NVIDIA/TensorRT
cd TensorRT
git checkout release/8.0
cd python
CPATH=$EXT_PATH/pybind11/include TRT_OSSPATH=$EXT_PATH/TensorRT \
PYTHON_MAJOR_VERSION=3 PYTHON_MINOR_VERSION=8 TARGET=aarch64 \
./build.sh

python3 -m pip uninstall tensorrt -y
python3 -m pip install build/dist/tensorrt-*.whl
cd $EXT_PATH

python3 -c "import tensorrt"

https://github.com/mlcommons/inference_results_v2.0/issues/2

你可能感兴趣的:(模型部署,人工智能,深度学习)