Ubantu16.04安装显卡驱动遇到的坑

在Ubantu下安装显卡驱动,步骤相对较繁琐,但本文经过博主的亲身实践,非常有效

首先我们先要查看版本驱动:https://www.nvidia.com/Download/index.aspx?lang=en-us

1.下载Linux下的显卡驱动,保存到home文件夹下。

2. 卸载原有的驱动,对于第一次安装应该可以省略此步骤

#for case1: original driver installed by apt-get:
sudo apt-get remove --purge nvidia*
 
#for case2: original driver installed by runfile:
sudo chmod +x *.run
sudo ./NVIDIA-Linux-x86_64-xxx.xx.run --uninstall
3.禁用nouveau

sudo gedit /etc/modprobe.d/blacklist.conf

在文件的最后一行添加 : blacklist nouveau

之后执行命令:  sudo update-initramfs -u

重启后执行 :lsmod | grep nouveau #没有输出,即说明安装成功

即:


4.安装驱动:

(1)进入tty模式:Ctrl+Alt+F1 输入用户名和密码登录即可。

(2)给驱动run文件赋予执行权限(若出现[sudo] 计算机名 ◆ ◆ ◆ ◆,这是因为安装了中文的ubuntu,输入登录密码即可)

由于run文件放在了home文件夹下,故

cd ./ 注意空格

sudo chmod a+x NVIDIA-Linux-x86_64-xxx.xx.run

(3)安装:cd ./
sudo sh ./NVIDIA-Linux-x86_64-410.78.run -no-x-check -no-nouveau-check -no-opengl-files
//只有禁用opengl这样安装才不会出现循环登陆的问题
-no-x-check:安装驱动时关闭X服务
-no-nouveau-check:安装驱动时禁用nouveau
-no-opengl-files:只安装驱动文件,不安装OpenGL文件

(4)安装过程中的一些选项:The distribution-provided pre-install script failed! Are you sure you want to continue?
选择 yes 继续。
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 继续。
问题没记住,选项是:install without signing
问题大概是:Nvidia’s 32-bit compatibility libraries? 选择 No 继续。
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 继续。这些问题并不是每个人都能碰到,碰到某个,按上面的提示做即可。

4.检查驱动是否安装成功

modprobe nvidia    挂载驱动
nvidia-smi     检查驱动是否安装成功
如果出现如下提示,则说明安装成功:

Ubantu16.04安装显卡驱动遇到的坑

5.重启机器即可 reboot

本文借鉴了两篇博主的文章,有兴趣的可以查看

https://blog.csdn.net/weixin_42546496/article/details/88640174

https://blog.csdn.net/ghw15221836342/article/details/79571559