1,官方下载驱动
下载好的驱动文件:NVIDIA-Linux-x86_64-525.105.17.run
2,屏蔽nouveau驱动
sudo vim /etc/modprobe.d/blacklist.conf
最后一行添加以下几行语句,保存退出
blacklist nouveau
options nouveau modeset=0
更新文件
sudo update-initramfs -u
重启
sudo reboot
验证屏蔽是否成功
lsmod | grep nouveau # 没有信息显示,说明nouveau已被禁用
3,安装驱动
命令行安装,退出ubunt图像化界面,改为命令行
修改驱动文件权限
sudo chmod a+x NVIDIA-Linux-x86_64-525.105.17.run
执行安装
sudo ./NVIDIA-Linux-x86_64-xxx.run -no-x-check -no-nouveau-check -no-opengl-files
# -no-x-check:安装驱动时关闭X服务
# -no-nouveau-check:安装驱动时禁用nouveau
# -no-opengl-files:只安装驱动文件,不安装OpenGL文件
安装过程选项:
The distribution-provided pre-install script failed! Are you sure you want to continue?
Continue installation Abort installation (选择 Cotinue)
Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later.
Yes No (选 No)
Install NVIDIA’s 32-bit compatibility libraries?
Yes No (选 No)
Installation of the kernel module for the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version 390.42) is now complete.
OK
检查驱动是否安装成功:
nvidia-smi
4,驱动卸载
sudo /usr/bin/nvidia-uninstall(亲测可以)
sudo apt-get --purge remove nvidia*
sudo apt-get --purge remove "*nvidia*"
sudo apt autoremove
sudo apt-get --purge remove "*cublas*" "cuda*" # remove CUDA Toolkit
5,驱动更新
卸载驱动,安装高版本nvidia驱动后,ssh服务器出现Destination Host Unreachable
目前解决办法(服务器休眠):
执行以下命令查看机器是否自动休眠:
systemctl status sleep.target
关闭自动休眠
sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
查看
systemctl status sleep.target