ubuntu18.04+cuda11.2+cudnn8.0.5+Tensorrt7.2.2.3安裝
環境
系統:ubuntu 18.04
編譯器:gcc 7.5
如果之前安裝過deb格式的tensorrt,需要卸載
卸載tensorrt
sudo apt-get purge "libnvinfer*"
sudo apt-get purge graphsurgeon-tf onnx-graphsurgeon
sudo apt-get purge uff-converter-tf
如果用pip安裝過對應的包(根據自己安裝過的包卸載)
sudo pip3 uninstall tensorrt
sudo pip3 uninstall uff
sudo pip3 uninstall graphsurgeon
sudo pip3 uninstall onnx-graphsurgeon
刪除key
由於之前安裝過其他版本的tensorrt,安裝新的tensorrt時會默認安裝key中最新版本的tensorrt,因此想要安裝老版本的tensorrt需要刪除其他版本的key。
查看key
sudo apt-key list
查看key列表
ls /etc/apt/source.list.d
刪除key
sudo rm /etc/apt/source.list.d/nv-tensorrt-ubuntu1804-cuda11.3-trt8.0.0.3-ea-20210423.list
刪除安裝包
sudo rm -rf /var/nv-tensorrt-repo-cuda11.3-trt8.0.0.3-ga-20201211
安裝tensorrt
deb版本
cuda和cudnn也要是deb安裝
os="ubuntuxx04"
tag="cudax.x-trt8.x.x.x-ea-yyyymmdd"
sudo dpkg -i nv-tensorrt-repo-${os}-${tag}_1-1_amd64.deb
sudo apt-key add /var/nv-tensorrt-repo-${tag}/7fa2af80.pub
sudo apt-get update
sudo apt-get install tensorrt
驗證
dpkg -l | grep TensorRT
進入/var/nv-tensorrt-repo-ubuntu1804-cuda11.1-trt7.2.3.4-ga-20210226
安裝剩下的包,eg:uff
sudo apt-get install uff-converter-tf
如果要安裝python接口,下載壓縮包版本的tensorrt,在解壓后的目錄中通過pip安裝對應的whl
sudo pip3 install TensorRT-${version}/python/tensorrt-*-cp3x-none-linux_x86_64.whl
可能會遇到部分包缺失依賴
libnvinfer-bin : Depends: libnvinfer-plugin7 (= 7.2.2-1+cuda11.1) but it is not going to be installed
Depends: libnvparsers7 (= 7.2.2-1+cuda11.1) but it is not going to be installed
Depends: libnvonnxparsers7 (= 7.2.2-1+cuda11.1) but it is not going to be installed
安裝對應的依賴
sudo apt-get install libnvinfer-plugin7 (= 7.2.2-1+cuda11.1
驗證
cp /usr/src/tensorrt ~/
cd ~/tensorrt/sample/sampleMNIST
make
cd ~/tensorrt/bin
./sample_mnist
如果提示數據不存在,進入data/mnist
目錄,運行download_pgms.py
下載數據
編譯好的壓縮包安裝
解壓壓縮包
version="8.x.x.x"
arch=$(uname -m)
cuda="cuda-x.x"
cudnn="cudnn8.x"
tar xzvf TensorRT-${version}.Linux.${arch}-gnu.${cuda}.${cudnn}.tar.gz
寫入路徑
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<TensorRT-${version}/lib>
如果要安裝python接口,在解壓后的目錄中通過pip安裝對應的whl
sudo pip3 install TensorRT-${version}/python/tensorrt-*-cp3x-none-linux_x86_64.whl
驗證
cp /usr/src/tensorrt ~/
cd ~/tensorrt/sample/sampleMNIST
make
cd ~/tensorrt/bin
./sample_mnist
如果提示數據不存在,進入data/mnist
目錄,運行download_pgms.py
下載數據
可能遇到的問題
libm.so.6: version `GLIBC_2.27‘ not found
問題libm.so.6: version `GLIBC_2.27‘ not found的解決方法
終端輸入strings /lib/x86_64-linux-gnu/libm.so.6 | grep GLIBC_
ubuntu16.04會得到:GLIBC_2.2.5
、GLIBC_2.4
、GLIBC_2.15
、GLIBC_2.18
、GLIBC_2.23
ubuntu18.04會得到:GLIBC_2.2.5
、GLIBC_2.4
、GLIBC_2.15
、GLIBC_2.18
、GLIBC_2.23
、GLIBC_2.24
、GLIBC_2.25
、GLIBC_2.26
、GLIBC_2.27
本質上是ubuntu16.04安裝成了ubuntu18.04的版本