ubuntu22.04 cuda cudnn tensorRT安装
1:查看当前安装驱动版本信息
driver version: 525.116.03
cuda version: 12.0
注意:nvidia官网下载和打开巨慢的问题
把nvidia.com换成nvidia.cn
2:下载 cuda version 12.0版本并安装
https://developer.nvidia.com/cuda-toolkit-archive
https://developer.nvidia.com/cuda-12-0-0-download-archive
wget https://developer.download.nvidia.com/compute/cuda/12.0.0/local_installers/cuda_12.0.0_525.60.13_linux.run
sudo sh cuda_12.0.0_525.60.13_linux.run
在.bashrc文件中加入下面的环境变量
vim ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.0/lib64
export PATH=$PATH:/usr/local/cuda-12.0/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-12.0
验证
3:安装cudnn
https://developer.nvidia.com/rdp/cudnn-archive
解压安装
tar -xvf cudnn-linux-x86_64-8.8.0.121_cuda12-archive.tar.xz
cd cudnn-linux-x86_64-8.8.0.121_cuda12-archive
sudo cp include/cudnn*.h /usr/local/cuda-12.0/include
sudo cp lib/libcudnn* /usr/local/cuda-12.0/lib64
sudo chmod a+r /usr/local/cuda-12.0/include/cudnn*.h /usr/local/cuda-12.0/lib64/libcudnn*
验证
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
4:安装 tensorRT
https://developer.nvidia.com/nvidia-tensorrt-8x-download
下载命令:
wget https://developer.nvidia.com/nvidia-tensorrt-8x-download#:~:text=TensorRT 8.6 GA for Linux x86_64 and CUDA 12.0 and 12.1 TAR Package
安装过程:
tar -xvf TensorRT-8.6.1.6.Linux.x86_64-gnu.cuda-12.0.tar.gz #解压
sudo mv TensorRT-8.6.1.6/ /usr/local/
在.bashrc文件中加入下面的环境变量
vim ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/TensorRT-8.6.1.6/lib
source ~/.bashrc #生效
测试:
cd /usr/local/TensorRT-8.6.1.6/samples/sampleOnnxMNIST
make
cd /usr/local/TensorRT-8.6.1.6/bin
./sample_onnx_mnist