赞
踩
ubuntu 20.04 环境下安装CUDA 11.8, cuDNN v8.6.0和TensorRT 8.6.0(deb方式)
sudo wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-8-local_11.8.0-520.61.05-1_amd64.deb
sudo cp /var/cuda-repo-ubuntu2004-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
取消勾选驱动, 下一步
添加环境变量
sudo vim ~/.bashrc
最后一行添加:
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64:/usr/local/cuda-11.8/extras/CPUTI/lib64
export CUDA_HOME=/usr/local/cuda-11.8/bin
export PATH=$PATH:$LD_LIBRARY_PATH:$CUDA_HOME
保存关闭后,应用一下更改
source ~/.bashrc
下载 cuDNN v8.6.0 for CUDA 11.x
sudo dpkg -i cudnn-local-repo-ubuntu2004-8.6.0.163_1.0-1_amd64.deb
导入CUDA GPG key
sudo cp /var/cudnn-local-repo-ubuntu2004-8.6.0.163/cudnn-local-B0FE0A41-keyring.gpg /usr/share/keyrings/
刷新存储库元数据
sudo apt-get update
进入 cudnn-local 目录
cd /var/cudnn-local-repo-ubuntu2004-8.6.0.163
安装
sudo apt-get install libcudnn8=8.6.0.163-1+cuda11.8
sudo apt-get install libcudnn8-dev=8.6.0.163-1+cuda11.8
sudo apt-get install libcudnn8-samples=8.6.0.163-1+cuda11.8
sudo dpkg -i nv-tensorrt-local-repo-ubuntu2004-8.6.0-cuda-11.8_1.0-1_amd64.deb
sudo cp /var/nv-tensorrt-local-repo-ubuntu2004-8.6.0-cuda-11.8/*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
# 安装 tensorrt
sudo apt-get install tensorrt
# 如果使用 Python
sudo apt-get install python3-libnvinfer-dev
# 如果转换 onnx 模型
sudo apt-get install onnx-graphsurgeon
# 如果转换 TensorFlow 模型
sudo apt-get install uff-converter-tf
# 验证 TensorRT 是否安装成功
dpkg-query -W tensorrt
# tensorrt 8.6.0.12-1+cuda11.8
sudo rm -rf /usr/local/cuda/include/cudnn.h
sudo rm -rf /usr/local/cuda/lib64/libcudnn*
# 查询
sudo dpkg -l | grep cudnn
# 将查询结果全部卸载
sudo dpkg -r libcudnn8-samples
sudo dpkg -r libcudnn8-dev
sudo dpkg -r libcudnn8
sudo dpkg -r cudnn-local-repo-ubuntu2004-8.6.0.163
sudo apt-get remove cuda
sudo apt autoremove
sudo apt-get remove cuda*
#删除对应的cuda版本文件夹
cd /usr/local/
sudo rm -r cuda-****
#查看剩余的残留文件
sudo dpkg -l |grep cuda
#卸载对应的残留文件
sudo dpkg -P 残留文件名
参考文档:
1 NVIDIA CUDA Installation Guide for Linux
2 NVIDIA cuDNN Documentation
3 NVIDIA Deep Learning TensorRT Documentation
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。