安装TensorRT

下载对应的tar版本:https://developer.nvidia.com/nvidia-tensorrt-6x-download

  1. 解压安装包
version="6.0.1.8"
os="Ubuntu-16.04"
arch=$(uname -m)
cuda="cuda-10.2"
cudnn="cudnn7.6"
tar xzvf TensorRT-${version}.${os}.${arch}-gnu.${cuda}.${cudnn}.tar.gz
  1. 解压得到TensorRT-6.0.1.8的文件夹,将里边的lib绝对路径添加到环境变量中
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/qian/TensorRT-6.0.1.8/lib
  1. 安装TensorRT
cd TensorRT-${version}/python

# If using Python 2.7:
sudo pip2 install tensorrt-*-cp27-none-linux_x86_64.whl

# If using Python 3.x:
sudo pip3 install tensorrt-*-cp3x-none-linux_x86_64.whl
  1. 安装Python UFF wheel文件。仅当计划将TensorRT与TensorFlow一起使用时,才需要此选项。
cd TensorRT-${version}/uff

# If using Python 2.7:
sudo pip2 install uff-0.6.9-py2.py3-none-any.whl

# If using Python 3.x:
sudo pip3 install uff-0.6.9-py2.py3-none-any.whl

# In either case, check the installation with:
which convert-to-uff
  1. Install the Python graphsurgeon wheel file.
cd TensorRT-${version}/graphsurgeon

# If using Python 2.7:
sudo pip2 install graphsurgeon-0.4.5-py2.py3-none-any.whl

# If using Python 3.x:
sudo pip3 install graphsurgeon-0.4.5-py2.py3-none-any.whl

  1. 为了避免后边deepstream找不到tensorrt的库,建议把tensorrt的库和头文件添加到系统路径下
# TensorRT路径下
sudo cp -r ./lib/* /usr/lib
sudo cp -r ./include/* /usr/include
  1. 如果要使用python接口的tensorrt,则需要安装pycuda
pip install 'pycuda>=2019.1.1'
  1. 测试
cd ~/TensorRT-6.0.1.8/samples/
sudo make
cd ../bin
./sample_int8 mnist

你可能感兴趣的:(深度学习)