系统相关
首页 > 系统相关> > Ubuntu18.04 安装cuda-10.2 cudnn7.6.5.32 tensorrt7.0.0.11

Ubuntu18.04 安装cuda-10.2 cudnn7.6.5.32 tensorrt7.0.0.11

作者:互联网

一、安装cuda-10.2

下载网址 CUDA Toolkit 10.2 download

在这里插入图片描述
执行:

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
# 切换到cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb目录下
sudo dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
sudo apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
sudo apt-get update
sudo apt-get -y install cuda

添加环境变量:

nano ~/.bashrc

在最后添加:

export PATH="/usr/local/cuda-10.2/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH"

重启,执行:

nvcc -V

执行:

nvidia-smi

二、安装cuDNN

下载地址:cuDNN
一定要注意版本,否则安装会失败!!!!!
cudnn

# 安装,顺序一定按照以下顺序
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.2_amd64.deb

验证cuDNN在Linux上是否安装成功。为了验证cuDNN已经安装并正确运行,需要编译位于/usr/src/cudnn_samples_v7目录下的mnistCUDNN样例:

# 将cuDNN示例复制到可写路径
$ cp -r /usr/src/cudnn_samples_v7/ $HOME
# 进入到可写路径
$ cd  $HOME/cudnn_samples_v7/mnistCUDNN
# 编译mnistCUDNN示例
$ make clean && make
# 运行mnistCUDNN示例
$ ./mnistCUDNN

运行结果出现:

Test passed!

则代表安装成功!!

三、安装Tensorrt

下载地址:Tensorrt
注意cuda和cudnn版本!!
Tensorrt
1、解压:

tar -xzvf TensorRT-7.0.0.11.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz

2、解压得到TensorRT-7.0.0.11的文件夹,将里边的lib绝对路径添加到环境变量中

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/qian/TensorRT-7.0.0.11/lib"

3、安装TensorRT

cd TensorRT-7.0.0.11/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

4、安装Python UFF wheel文件,仅当计划将TensorRT与TensorFlow一起使用时,才需要此选项。

cd TensorRT-7.0.0.11/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

5、安装Python graphsurgeon

cd TensorRT-7.0.0.11/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

6、为了避免后边deepstream找不到tensorrt的库,建议把tensorrt的库和头文件添加到系统路径下

# TensorRT路径下
sudo cp -r ./lib/* /usr/lib
sudo cp -r ./include/* /usr/include

7、如果要使用python接口的tensorrt,则需要安装pycuda

pip3 install pycuda

8、测试

cd ~/TensorRT-7.0.0.11/data/mnist
python3 download_pgms.py

cd ~/TensorRT-7.0.0.11/samples/sampleMNIST
make clean
make
cd ~/TensorRT-7.0.0.11/bin
./sample_mnist

标签:10.2,tensorrt7.0,sudo,TensorRT,7.0,cudnn7.6,0.11,cuda
来源: https://blog.csdn.net/qq_45032341/article/details/120217191