安装 cudnn ¶
环境前提 ¶
- 基于 Ubuntu 22.04.2 LTS
1. 官网下载 ¶
官网(需要注册):https://developer.nvidia.com/cudnn
下载完,拷贝到服务器 手册: https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#installlinux-tar
sh
# 推荐内网下载(建议)
wget http://minio.10yun.host:9000/mirrors/nvidia/cudnn/cudnn-linux-x86_64-8.9.0.131_cuda12-archive.tar.xz
# 解压
tar -xvf cudnn-linux-x86_64-8.9.0.131_cuda12-archive.tar.xz
# 将以下文件复制到 CUDA 工具包目录中
sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
sudo cp -P cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
1. 镜像源下载(未完成) ¶
- 下载
sh
# cuda 12.0
wget https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/libcudnn8_8.8.1.3-1+cuda12.0_amd64.deb
# cuda 12.1
wget https://developer.download.nvidia.cn/compute/cuda/repos/ubuntu2004/x86_64/libcudnn8_8.9.0.131-1+cuda12.1_amd64.deb
- 解压并安装deb包
sh
# cuda 12.0
chmod 777 libcudnn8_8.8.1.3-1+cuda12.0_amd64.deb
sudo dpkg -i libcudnn8_8.8.1.3-1+cuda12.0_amd64.deb
# cuda 12.1
sudo dpkg -i libcudnn8_8.9.0.131-1+cuda12.1_amd64.deb
sh
tar -xzvf libcudnn8_8.8.1.3-1+cuda12.0_amd64.deb
# 或者
tar -xzvf libcudnn8_8.9.0.131-1+cuda12.1_amd64.deb
- 复制到cuda工具包
sh
# 安装
sudo cp cuda/include/cudnn*.h /usr/local/cuda-12.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-12.0/lib64
sudo chmod a+r /usr/local/cuda-12.0/include/cudnn*.h
sudo chmod a+r /usr/local/cuda-12.0/lib64/libcudnn*
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
2、配置环境变量(目前没用到) ¶
sh
# 添加环境变量
# echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.0/lib64:$LD_LIBRARY_PATH' >> ~/.zshrc
# source ~/.zshrc
3、验证 ¶
安装完成,检查是否安装成功
sh
cat /usr/local/cuda-12.0/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
如果成功安装,应该能够看到类似下面的输出
参考 ¶
https://blog.csdn.net/weixin_45730632/article/details/126641891