显卡 rtx3060,笔记本已经安装了 cuda 11.4 和 对应的cudnn;现在想要安装 cuda 11.8 和 cudnn 8.8
原理: 新的 driver 可以 兼容 旧的 cuda sdk;
旧的 driver 不能 兼容 新的cuda sdk;
下载 cuda 11.8
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
清理旧的driver
sudo apt-get purge nvidia*
sudo reboot
开始安装 cuda 11.8
sudo sh cuda_11.8.0_520.61.05_linux.run
选项选择:
continue
accept
yes(/usr/local/cuda -> new cuda version)
——安装后的提示内容——————————————————————————————
Please make sure that
- PATH includes /usr/local/cuda-11.8/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-11.8/lib64, or, add /usr/local/cuda-11.8/lib64 to /etc/ld.so.conf and run ldconfig as root
————————————————————————————————————————
sudo reboot
如果x起不来,可以试试执行:
$ sudo init 5
或者 进入advanced ubuntu 模式,启动后再回来
测试:
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
nvcc --version
下载官方示例:
$ git clone --recursive https://github.com/NVIDIA/cuda-samples.git
$ git tag
$ git checkout v11.8
编译运行
$ cd /cuda-samples/Samples/0_Introduction/vectorAdd
$ make
$ ./vectorAdd
打印:
Test PASSED
Done
—————————————————————————————————————————
安装cudnn_8.8
下载cudnn lib 需要nvidia 开发者账户
下载cudnnxxx.tar.xz
$ tar -xvf cudnnxxx.tar.xz
$ 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*
所有用户都能读
参考:
https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html
测试cudnn
$ git clone --recursive https://github.com/HangJie720/cudnn-samples.git
$ cd cudnn-samples/conv_sample
$ vim Makefile
将 SMS变量的值设置成自己的显卡,比如 rtx3060 为 86
#LL:: SMS ?= 30 35 50 53 60 61 $(SMS_VOLTA)
SMS ?= 86
$ make
$ conv_sample
打印:
Testing single precision
Testing conv
^^^^ CUDA : elapsed = 0.332502 sec,
Test PASSED
Testing half precision (math in single precision)
Testing conv
^^^^ CUDA : elapsed = 2.81334e-05 sec,
Test PASSED
切换:
改变软连接 ln -s /usr/local/cuda-11.4 /usr/local/cuda
版权归原作者 Eloudy 所有, 如有侵权,请联系我们删除。