1、将nouveau驱动加入黑名单
(1)打开blacklist.conf文件
sudo gedit /etc/modprobe.d/blacklist.conf
(2)在blacklist.conf文件中加入以下内容
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist rivatv
blacklist nvidiafb
(3)更新系统
sudo update-initramfs -u
(4)重启
(5)查看nouveau是否被禁止,输入以下命令,如果没有输出则说明被禁止
lsmod | grep nouveau
2、下载Nvidia驱动
在英伟达官网下载合适的驱动:https://www.nvidia.cn/Download/index.aspx?lang=cn
3、安装
(1)Ctrl+Alt+F1进入命令行界面,输入用户名和密码
(2)关闭图形界面
sudo service lightdm stop
(3)卸载原有的nvidia驱动
sudo apt-get remove nvidia-*
(4)进入到NVIDIA驱动下载的目录(我的是Download目录)
cd Download
(5)给NVIDIA驱动程序赋权限
sudo chmod a+x NVIDIA-Linux-x86_64-xxx.run
(6)安装NVIDIA驱动
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文件
(7)安装过程选择
1、he distribution-provided pre-install script failed! Are you sure you want to continue? 选择 yes 继续。
2、Would you like to register the kernel module souces with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later? 选择NO继续
3、Would 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 继续
(8)开启图形界面
sudo service lightdm start
(9)Ctrl+Alt+F7返回到ubuntu图形界面
(10)输入以下命令验证是否成功
nvidia-smi
另一种方法是通过ppa
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-390 #此处要根据上面查询到的版本适当更改
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
重启之后在终端内输入:
nvidia-smi #若出现电脑GPU列表,即安装成功
或者
nvidia-settings #显示你的显卡信息