如何在Ubuntu 20.04 Linux上安装NVIDIA驱动程序

手动安装使用官方nvidia.com驱动程序逐步说明

识别NVIDIA显卡型号:

$  lshw -numeric -C display
or
$ lspci -vnn | grep VGA
or
$ ubuntu-drivers devices

下载官方NVIDIA驱动程序。
使用Web浏览器导航到官方NVIDIA网站,并为NVIDIA显卡下载适当的驱动程序。
将得到一个类似的文件:

$ ls
NVIDIA-Linux-x86_64-440.44.run

为编译驱动准备以下工作

$ sudo apt install build-essential libglvnd-dev pkg-config

禁用默认的nouveau nvidia驱动程序。

停止桌面管理器。为了安装新的NVIDIA驱动程序,我们需要停止当前显示服务器。最简单的方法是使用“Telinit”命令更改为Runlevel 3. 执行以下Linux命令后,显示服务器将停止,因此请确保在继续之前保存所有当前的工作(如果有的话):

$ sudo telinit 3

点击“Ctrl + Alt + F1”,并使用用户名和密码登录以打开新的TTY1会话或者通过SSH登录。

开始安装NVIDIA驱动程序,并按照向导:

$ sudo bash NVIDIA-Linux-x86_64-440.44.run

重新启动系统:

$ sudo reboot

配置NVIDIA X服务器设置。
重新启动后,我们应该能够从“活动”菜单中启动NVIDIA X服务器设置应用程序。

常见问题:

错误消息:

WARNING: Unable to find suitable destination to install 32-bit compatibility libraries

根据需求,可以安全地忽略这一点。
但是,如果我们希望安装Steam游戏平台,则无法忽略此问题。
要解决这个问题,执行:

$ sudo dpkg --add-architecture i386
$ sudo apt update
$ sudo apt install libc6:i386

并重新运行NVIDIA驱动程序安装。

An incomplete installation of libglvnd was found. 
All of the essential libglvnd libraries are present, but one or more optional  components are missing. 
Do you want to install a full copy of libglvnd? This will overwrite any existing libglvnd libraries.

我们缺少libglvnd-dev包。
执行以下命令以解决此问题:

$ sudo apt install libglvnd-dev
Oct  9 10:36:20 onitroad gdm-password]: gkr-pam: unable to locate daemon control file
Oct  9 10:36:20 onitroad gdm-password]: pam_unix(gdm-password:session): session opened for user onitroad by (uid=0)
Oct  9 10:36:20 onitroad systemd-logind[725]: New session 8 of user onitroad.
Oct  9 10:36:20 onitroad systemd: pam_unix(systemd-user:session): session opened for user onitroad by (uid=0)
Oct  9 10:36:21 onitroad gdm-password]: pam_unix(gdm-password:session): session closed for user onitroad
Oct  9 10:36:21 onitroad systemd-logind[725]: Session 8 logged out. Waiting for processes to exit.
Oct  9 10:36:21 onitroad systemd-logind[725]: Removed session 8.
Oct  9 10:36:45 onitroad dbus-daemon[728]: [system] Failed to activate service 'org.bluez': timed out (service_start_timeout=25000ms)

在NVIDIA驱动程序安装期间,解析不会覆盖任何现有的libglvnd库。

WARNING: Unable to determine the path to install the libglvnd EGL vendor library config files. 
Check that you have pkg-config and   the libglvnd development libraries installed, 
or specify a path with --glvnd-egl-config-path.

确保安装了pkg-config包:

$ sudo apt install pkg-config

使用标准Ubuntu存储库执行自动NVIDIA驱动程序安装

检测NVIDIA显卡的型号和推荐的驱动程序。

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C03sv00001043sd000085ABbc03sc00i00
vendor   : NVIDIA Corporation
model    : GP106 [GeForce GTX 1060 6GB]
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-435 - distro non-free
driver   : nvidia-driver-440 - distro non-free recommended
driver   : xserver-xorg-video-nouveau - distro free builtin

当前系统具有NVIDIA GeForce GTX 1060 6GB图形卡,并推荐的驱动器安装是NVIDIA-Driver-440。
安装驱动程序。如果同意推荐,使用“Ubuntu-Drivers”命令安装所有推荐的驱动程序:

$ sudo ubuntu-drivers autoinstall

或者,使用“APT”命令选择性地安装所需的驱动程序。例如:

$ sudo apt install nvidia-driver-440

完成安装后,重新启动系统

$ sudo reboot

自动安装使用PPA存储库安装NVIDIA Beta驱动程序

添加ppa:graphics-drivers/ppa存储库到系统:

$ sudo add-apt-repository ppa:graphics-drivers/ppa

识别显卡型号和推荐的驱动程序:

$ ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:01.0/0000:01:00.0 ==
modalias : pci:v000010DEd00001C03sv00001043sd000085ABbc03sc00i00
vendor   : NVIDIA Corporation
model    : GP106 [GeForce GTX 1060 6GB]
driver   : nvidia-driver-440 - distro non-free recommended
driver   : nvidia-driver-390 - distro non-free
driver   : nvidia-driver-435 - distro non-free
driver   : xserver-xorg-video-nouveau - distro free builtin

安装nvidia驱动程序,可以自动安装所有推荐的驱动程序:

$ sudo ubuntu-drivers autoinstall

或者使用“APT”命令选择性地安装。

$ sudo apt install nvidia-driver-440

重新启动计算机:

$ sudo reboot
日期:2020-07-07 20:55:31 来源:oir作者:oir