Ubuntu 16.04 安装nvidia驱动

https://blog.csdn.net/weixin_42731241/article/details/103473729

环境

笔记本:技嘉

操作系统:ubuntu 16.04LTS 显卡:nvidia Geforce`GTX 1070 

安装步骤

(安装方式——手动run文件安装)

1.搜索驱动程序下载

在NVIDIA驱动官网选择参数搜索后,下载,本次下载驱动为NVIDIA-Linux-x86_64-440.36.run

2.卸载旧驱动

卸载可能存在的旧版本 nvidia 驱动(对没有安装过 nvidia 驱动的主机,这步可以省略,但推荐执行,无害),如果你安装失败了也需要执行这一步

 sudo apt-get remove --purge nvidia*
 #若安装失败也是这样卸载以及
 ./NVIDIA-Linux-x86_64-390.48.run --uninstall #确保卸载干净。
3.安装可能需要的依赖

#其实很多你的环境已经安装了,所以一般并没有多少时间。
 sudo apt-get update 
 sudo apt-get install dkms build-essential linux-headers-generic
 sudo apt-get install gcc-multilib xorg-dev
 sudo apt-get install freeglut3-dev libx11-dev libxmu-dev install libxi-dev  libgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
4.禁用noueau驱动

 sudo vi /etc/modprobe.d/blacklist-nouveau.conf 
 #在文件 blacklist-nouveau.conf 中加入如下内容:
  blacklist nouveau
  blacklist lbm-nouveau
  options nouveau modeset=0
  alias nouveau off
  alias lbm-nouveau off
  #保存   :wq
#禁用nouveau 内核模块
echo options nouveau modeset=0 | sudo tee -a /etc/modprobe.d/nouveau-kms.conf
sudo update-initramfs -u
reboot #重启
lsmod |grep nouveau #无显示则成功 当然驱动没了你的桌面分辨率会比较大。
5.进入blos关闭secure boot 

一定要关闭,否则无法安装成功

技嘉笔记本重启“F2”进入,[security]->[Delete All Secure Boot Variables],选择[Yes],[Secure Boot]将从[Active]变为[Not Active],"F10"保存并退出

6.进入tty关闭图形界面

按 CTRL + ALT + F1 键进入,登录

sudo service lightdm stop
#为了重建视频输出,必须先将其暂停
7. 运行.run文件选择合适选项

cd 下载目录
chmod a+x NVIDIA-Linux-x86_64-440.36.run #添加权限
sudo ./NVIDIA-Linux-x86_64-440.36.run --dkms --no-opengl-files
–no-opengl-files:表示只安装驱动文件,不安装OpenGL文件。这个参数不可省略,否则会导致登陆界面死循环,英语一般称为”login loop”或者”stuck in login”。
当然脸红的情况下并不会。
必选参数解释:因为NVIDIA的驱动默认会安装OpenGL,而Ubuntu的内核本身也有OpenGL、且与GUI显示息息相关,一旦NVIDIA的驱动覆写了OpenGL,在GUI需要动态链接OpenGL库的时候就引起问题。
–no-x-check:表示安装驱动时不检查X服务,非必需,我们已经禁用图形界面。
–no-nouveau-check:表示安装驱动时不检查nouveau,非必需,我们已经禁用驱动。
-Z, –disable-nouveau:禁用nouveau。此参数非必需,因为之前已经手动禁用了nouveau。
-A:查看更多高级选项。
-dkms(默认开启)在 kernel 自行更新时将驱动程序安装至模块中,从而阻止驱动程序重新安装。在 kernel 更新期间,dkms 触发驱动程序重编译至新的 kernel 模块堆栈。
8.安装过程中的问题

1.If you plan to no longer use the NVIDIA deriver, you should make sure that no X screens are configured to use the NVIDIA X driver X driver in your X configuration file. If you used nvidia-xconfig to configure X, it may have created  a backup of your original configuration. Would you like to run 'nvidia-xconfig --restore-original-backup' to attempt restoration of the original X configuration file?

选择 no 继续

2.Would you like to run the nvidia-xconfig utility to automatically updata your X onfiguration file so that the NVIDIA X driver will be used when you restart X? Any pre-existing X configuration file will be backed up.

选择 no 继续

3.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 继续

4.问题大概是:Nvidia’s 32-bit compatibility libraries?

选择 no 继续

5.Kernel module compilation complete.The target kernel has CONFIG_MODULE_SIG set. which means that is supports 

cryptographic signature on kernel modules. On some system, the kernel may refuse 

to load modules without a valid signature from a trusted key. This system also has 

UEFI Secure Boot enabled; many distrubtions enforce module signature verification

on UEFI systems when Secure Boot is enabled(2). Would you like sign the NVIDIA kernel

module? (Answer: Install without signing)

Kernel module load error: Required key not avaliable

ERROR: The kernel module failed to load, because it was not signed by a key

                that is trusted by the kernel. Please try installing the driver again. 

                and sign the kernel when prompted to do so.

ERROR:  Unable to load the kernel module 'nvidia.ko'. This happens most 

                frequently when this kernel module was built against the wrong or

                improperly configured kernel sources, with a version of gcc that 

                differs from the one used to build the target kernel(1), or if a driver 

                such as rivafb, nvidiafb. or nouveau is present and prevents the 

                NVIDIA kernel module from obtaining ownership of the NVIDIA 

                graphics device(s), or no NVIDIA GPU installed in this system is 

                supported by this NVIDIA Linux graphics driver release.

以上错误简要描述了 NVIDIA 由于由于Ubuntu 16.04 的内核编译默认设置了 CONFIG_MODULE_SIG 为真, 然后Secure Boot打开所带来的问题, 更详细的描述见参考链接[2][3]. 大意是在支持UEFI的设备上打开Secure Boot 后,Ubuntu 16.04对于添加到内核的模块更加保守, 需要持有签名才能添加到模块中, 而显卡驱动由于要添加到内核中, 所以需要签名. 在安装过程中我们也会看到NVIDIA显卡会提示是否生成签名. 如果生成成功则没有问题,如果失败则,进入BIOS关闭Secure Boot

9.安装完成后验证

nvidia-smi #若列出GPU的信息列表,表示驱动安装成功
若失败则跳回2卸载后重新开始

【参考】

最全面解析 Ubuntu 16.04 安装nvidia驱动 以及各种错误

ubuntu 上NVIDIA驱动和CUDA9.0 的坑之一二

安装驱动时的问题
————————————————
版权声明:本文为CSDN博主「Rani_zZ」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42731241/article/details/103473729

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值