Linux下安装CUDA、CUDNN、TensorRT

Ubuntu 20.04 CUDA 11.8 CUDNN 8.6.0 TensorRT8.5.2

CUDA

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
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 gedit ~/.bashrc

在最后加入

export PATH=/usr/local/cuda-11.8/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.8/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

验证:

nvidia-smi
#或者
nvcc -V
#不好使重启试试

参考链接: CUDA Toolkit 11.8 Downloads | NVIDIA Developer

CUDNN

cuDNN Archive | NVIDIA Developer

下载需要注册Nvidia Develop账号,这里不再赘述

Linux下安装CUDA、CUDNN、TensorRT_第1张图片

下载后

sudo dpkg -i cudnn-local-repo-${distro}-8.x.x.x_1.0-1_amd64.deb
sudo cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install libcudnn8=8.x.x.x-1+cudaX.Y
sudo apt-get install libcudnn8-dev=8.x.x.x-1+cudaX.Y
sudo apt-get install libcudnn8-samples=8.x.x.x-1+cudaX.Y

(版本号和文件名使用Tab补全) 

如果之后找不到cudnn可以执行

sudo cp cuda/include/cudnn* /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn* /usr/local/cuda/lib64/libcudnn*

参考链接:Installation Guide - NVIDIA Docs 

 TensorRT

https://developer.nvidia.com/nvidia-tensorrt-8x-download

下载需要注册Nvidia Develop账号,这里不再赘述

Linux下安装CUDA、CUDNN、TensorRT_第2张图片

sudo dpkg -i nv-tensorrt-local-repo-${os}-${tag}_1.0-1_amd64.deb
sudo cp /var/nv-tensorrt-local-repo-${os}-${tag}/*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get install tensorrt

(版本号和文件名使用Tab补全)

验证:

dpkg -l | grep TensorRT

参考链接: Installation Guide :: NVIDIA Deep Learning TensorRT Documentation

你可能感兴趣的:(linux)