最近折腾了一下英伟达(NVIDIA)显卡驱动,安装过程略艰辛,所以记录下来,以避免读者朋友们踩坑。
在命令行输入:lspci |grep VGA
ubuntu@ubuntu:~$ lspci |grep VGA
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GP104 [GeForce GTX 1060] (rev a1)
在英伟达官网选择相应的显卡驱动下载。
下载好的驱动文件后缀名为.run,如:
Ubuntu系统集成的显卡驱动程序是第三方为NVIDIA开发的开源驱动nouveau,安装NVIDIA官方驱动之前需要先将其屏蔽。 先把nouveau驱动加到黑名单blacklist.conf里。
1)修改blacklist.conf文件属性
ubuntu@ubuntu:~$sudo chmod 666 /etc/modprobe.d/blacklist.conf
2)用gedit打开
ubuntu@ubuntu:~$sudo gedit /etc/modprobe.d/blacklist.conf
3)在最后一行下面添加以下几行语句,保存退出
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb
4)更新文件
ubuntu@ubuntu:~$ sudo update-initramfs -u
重启(必须重启)
5)验证nouveau是否已禁用
ubuntu@ubuntu:~$ lsmod | grep nouveau
没有信息显示,说明nouveau已被禁用,接下来可以安装nvidia的显卡驱动。
1)进入tty2
按ctrl+alt+fn(可以从f1到f12都去试一遍,我的是ctrl+alt+f1,只要有一个能进入命令行界面就行),进入进入tty2之后会看显示
Ubuntu 16.04.4 LTS Ubuntu64 tty2
ubuntu64 login:
按照提示输入用户名和密码。
2)关闭图形界面
ubuntu@ubuntu:~$ sudo service lightdm stop
3)卸载原有驱动
进入到NVIDIA-Linux-x86_64-xxx.run文件目录中,如果之前安装过其他版本驱动或以其他方式安装过驱动则执行以下命令卸载掉原有驱动:
ubuntu@ubuntu:~$ sudo apt-get remove nvidia-*
4)修改驱动文件权限
ubuntu@ubuntu:~$ sudo chmod a+x NVIDIA-Linux-x86_64-xxx.run
5)执行安装
ubuntu@ubuntu:~$ sudo ./NVIDIA-Linux-x86_64-xxx.run -no-x-check -no-nouveau-check -no-opengl-files
安装过程:
过程中根据提示,选择Accept等。
There appears to already be a driver installed on your system (version:
390.42). As part of installing this driver (version: 390.42), the existing driver will be uninstalled. Are you sure you want to continue?
Continue installation Abort installation (选择Coninue)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.
OKWould you like to run the nvidia-xconfigutility to automatically update your x configuration so that the NVIDIA x driver will be used
when you restart x? Any pre-existing x confile will be backed up.
Yes No (这里选 Yes)
如果不小心选择错误,不要紧,安装失败重来一次就好。
ubuntu@ubuntu:~$ modprobe nvidia
检查驱动是否安装成功:
ubuntu@ubuntu:~$ nvidia-smi