1.nvidia-smi看看对应驱动的版本,如果没有还得先去下载驱动,https://www.nvidia.com/
2.安装cuda, https://developer.nvidia.com/cuda-downloads
sudo sh cuda_10.1.105_418.39_linux.run 安装
设置环境变量:
sudo gedit ~/.bashrc
末尾输入:
export CUDA_HOME=/usr/local/cuda
export PATH=$PATH:$CUDA_HOME/bin
export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
刷新环境变量:
source ~/.bashrc
查看cuda版本命令:cat /usr/local/cuda/version.txt
3.安装cudnn,https://developer.nvidia.com/rdp/cudnn-download
解压:
tar -zxvf cudnn-10.1-linux-x64-v7.6.2.24.tgz
拷贝:
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
查看版本:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2