查看显卡是否存在
$ lspci | grep -i vga
禁用Nouveau驱动
$ sudo vi /etc/modprobe.d/blacklist.conf
blacklist nouveau
:wq
使用 dracut重新建立 initramfs p_w_picpath file
#备份 the initramfs file
$ sudo mv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak
#重新建立 the initramfs file
$ sudo dracut -v /boot/initramfs-$(uname -r).img $(uname -r)
开机默认文本模式
$ systemctl get-default
multi-user.target
$ sudo systemctl set-default multi-user.target
重启,检查ouveau driver确保没有被加载
$ sudo reboot
$ lsmod | grep nouveau
安装依赖
yum install epel-release
yum install --enablerepo=epel dkms
下载文件并安装
在官网选择要下载文件的版本: https://developer.nvidia.com/cuda-downloads
$ wget https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
$ sudo chmod +x cuda_11.1.0_455.23.05_linux.run
$ sudo ./cuda_11.1.0_455.23.05_linux.run
accept
Install
提示:
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.1/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Logfile is /var/log/cuda-installer.log
把PATH和LD_LIBRARY_PATH添加到 .bashrc,否则运行 nvcc -V 会提示错误 nvcc: 未找到命令
$ sudo vi .bashrc
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64
export PATH=$PATH:/usr/local/cuda-11.1/bin
查看安装结果
$ nvidia-smi # 显示的cuda版本是driver的
$ nvcc -V # 显示的cuda版本是runtime的,两者可能不一致。因为nvcc是 CUDA toolkit安装的,因此显示的是runtime的
参考:
https://cndaqiang.github.io/2019/03/31/cuda/
https://stackoverflow.com/questions/53422407/different-cuda-versions-shown-by-nvcc-and-nvidia-smi