安装步骤
1.查看是否安装了cuda
# 法1
cat /usr/local/cuda/version.txt
# 法2
nvcc --version
2.若没有安装,则查看是否有N卡驱动,若无N卡驱动,则到软件与更新 -> 附加驱动中安装驱动
3.查看N卡驱动支持的cuda版本
nvidia-smi
如下图支持最高CUDA版本是11.4
4.到cuda-toolkit-archive,选择需要的CUDA下载(https://developer.nvidia.com/cuda-11-4-0-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=18.04&target_type=runfile_local)
5.如下图,选择runfile(local)
,并使用生成的指令进行下载和安装
Installation Instructions:
$wget https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run$sudo sh cuda_11.4.0_470.42.01_linux.run
6.添加环境变量
vim ~/.bashrcexport PATH=/usr/local/cuda-11.4/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}source ~/.bashrc
7.验证是否安装成功
nvcc -V