- 系统:ubuntu20.04
- 硬件配置:GPU3080、CPU未知
- 通过《软件和更新》在附加驱动选项中添加了驱动:
1.检查自己电脑支持的cuda
bash
nvidia-smi
- 下载cuda11.4.2
bash
wget https://developer.download.nvidia.com/compute/cuda/11.4.2/local_installers/cuda_11.4.2_470.57.02_linux.run
sudo sh cuda_11.4.2_470.57.02_linux.run
会有卡顿,大概等1分钟;因之前安装了驱动,因此在下面的步骤中需要取消安装驱动。
- Continue
- accept
- 取消Driver
添加环境变量:
bash
gedit ~/.bashrc
#添加:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
#保存退出
source ~/.bashrc
测试CUDA
bash
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
sudo make -j4
./deviceQuery
--------------------------显示-----------------
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.4, CUDA Runtime Version = 11.4, NumDevs = 1
Result = PASS
安装CUDNN
https://developer.nvidia.com/cudnn (现在需要先登录才能下载)
下载cudnn-linux-x86_64-8.9.7.29_cuda11-archive.tar.xz
下载成功后解压复制
bash
tar zxvf cudnn-11.4-linux-x64-v8.2.4.15.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/