nvidia-smi
4. 下载cuda11.4.2
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分钟;因之前安装了驱动,因此在下面的步骤中需要取消安装驱动。
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
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
下载成功后解压复制
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/