Table of Contents
In this article, I will take you through the steps to install NVIDIA drivers on Ubuntu 20.04 LTS (Focal Fossa). As you might be aware that by default Ubuntu gets shipped with Nouveau open source drivers required by the NVIDIA graphics card. But this driver does not have the support for 3D acceleration and may not work properly as well with the latest NVIDIA video cards. So instead of using Nouveau drivers, you can use NVIDIA drivers developed by the NVIDIA itself. This driver provides excellent 3D acceleration and video card support with all the latest updates available.
How to Install NVIDIA drivers on Ubuntu 20.04 LTS (Focal Fossa)
Also Read: How to Install OpenComic Manga Reader on Ubuntu 20.04 LTS (Focal Fossa)
Step 1: Prerequisites
a) You should have a running Ubuntu 20.04 LTS
Server.
b) You should have sudo
or root
access to run privileged commands.
c) You should have apt-get
, ubuntu-drivers
and telinit
utility available in your System.
Step 2: Update Your Server
It is always recommended to keep the System updated with latest stable releases using apt update
command as shown below. If any of the packages needs to be upgraded then upgrade it by using apt-get upgrade
command as shown below.
root@cyberithub:~# apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Hit:5 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease
Hit:6 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease
Get:7 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:8 https://dl.google.com/linux/chrome/deb stable InRelease
Hit:9 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu focal InRelease
Hit:10 http://download.opensuse.org/repositories/home:/selmf/xUbuntu_20.04 InRelease
Hit:11 https://repo.protonvpn.com/debian stable InRelease
Get:12 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [1,712 kB]
...........................................
Step 3: Uninstall Nouveau drivers
Before installing NVIDIA drivers, you need to first uninstall the Nouveau drivers from the System by using apt-get --purge remove xserver-xorg-video-nouveau
command as shown below.
root@cyberithub:~# apt-get --purge remove xserver-xorg-video-nouveau
Step 4: Install NVIDIA drivers
There are multiple ways to install NVIDIA drivers but it is important to stick with one method you are choosing to follow through. For example - if you are using CLI method, then do not use any other method or else it tends to create multiple problems during installation.
a) Using Default Repository
You can check the currently attached NVIDIA devices and all the recommended drivers to install by using ubuntu-drivers devices
command as shown below.
root@cyberithub:~# ubuntu-drivers devices
You can choose to auto detect and install all the device drivers by using ubuntu-drivers autoinstall
command as shown below.
root@cyberithub:~# ubuntu-drivers autoinstall
Reading package lists... Done
Building dependency tree
Reading state information... Done
You can also search all the NVIDIA drivers by using apt search nvidia-driver
command as shown below.
root@cyberithub:~# apt search nvidia-driver Sorting... Done Full Text Search... Done nvidia-384/focal-updates,focal-security,focal 390.147-0ubuntu0.20.04.1 amd64 Transitional package for nvidia-driver-390 nvidia-384-dev/focal-updates,focal-security,focal 390.147-0ubuntu0.20.04.1 amd64 Transitional package for nvidia-driver-390 nvidia-driver-390/focal-updates,focal-security,focal 390.147-0ubuntu0.20.04.1 amd64 NVIDIA driver metapackage nvidia-driver-418/focal 430.50-0ubuntu3 amd64 Transitional package for nvidia-driver-430 nvidia-driver-418-server/focal-updates,focal-security 418.226.00-0ubuntu0.20.04.2 amd64 NVIDIA Server Driver metapackage .....................................
Then if you want to install some specific nvidia driver like nvidia-driver-470
, you can install it by using apt install nvidia-driver-470
command as shown below.
root@cyberithub:~# apt install nvidia-driver-470
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dctrl-tools dkms gcc-10-base:i386 libatomic1:i386 libbsd0:i386 libc6:i386 libcrypt1:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgcc-s1:i386 libgl1:i386 libgl1-mesa-dri:i386
libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libidn2-0:i386 libllvm12:i386 libnvidia-cfg1-470 libnvidia-common-470
libnvidia-compute-470 libnvidia-compute-470:i386 libnvidia-decode-470 libnvidia-decode-470:i386 libnvidia-encode-470 libnvidia-encode-470:i386
libnvidia-extra-470 libnvidia-fbc1-470 libnvidia-fbc1-470:i386 libnvidia-gl-470 libnvidia-gl-470:i386 libnvidia-ifr1-470 libnvidia-ifr1-470:i386
Finally reboot the system to load the driver in the Kernel.
root@cyberithub:~# init 6
b) Using PPA Repository
To install the driver through PPA repository, you need to first add the repository by using add-apt-repository ppa:graphics-drivers/ppa
command as shown below.
root@cyberithub:~# add-apt-repository ppa:graphics-drivers/ppa
Fresh drivers from upstream, currently shipping Nvidia.
## Current Status
Current long-lived branch release: `nvidia-430` (430.40)
Dropped support for Fermi series (https://nvidia.custhelp.com/app/answers/detail/a_id/4656)
Old long-lived branch release: `nvidia-390` (390.129)
For GF1xx GPUs use `nvidia-390` (390.129)
For G8x, G9x and GT2xx GPUs use `nvidia-340` (340.107)
For NV4x and G7x GPUs use `nvidia-304` (304.137) End-Of-Life!
Support timeframes for Unix legacy GPU releases:
https://nvidia.custhelp.com/app/answers/detail/a_id/3142
Update the System Cache with all the package information from all the enabled repo by using apt-get update
command as shown below.
root@cyberithub:~# apt-get update Hit:2 http://apt.postgresql.org/pub/repos/apt focal-pgdg InRelease Hit:3 http://in.archive.ubuntu.com/ubuntu focal InRelease Get:4 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB] Get:5 http://ppa.launchpad.net/graphics-drivers/ppa/ubuntu focal InRelease [24.3 kB] Get:6 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Hit:7 https://dl.google.com/linux/chrome/deb stable InRelease Hit:8 https://repo.protonvpn.com/debian stable InRelease Get:9 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB] Hit:10 http://ppa.launchpad.net/nilarimogard/webupd8/ubuntu focal InRelease
Then run ubuntu-drivers devices
to check all the devices and drivers.
root@cyberithub:~# ubuntu-drivers devices
You can choose to auto detect and install all the device drivers by using ubuntu-drivers autoinstall
command as shown below.
root@cyberithub:~# ubuntu-drivers autoinstall
You can also install any specific driver like nvidia-driver-470 using apt install nvidia-driver-470
command as shown below.
root@cyberithub:~# apt install nvidia-driver-470
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
dctrl-tools dkms gcc-10-base:i386 libatomic1:i386 libbsd0:i386 libc6:i386 libcrypt1:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386
libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgcc-s1:i386 libgl1:i386 libgl1-mesa-dri:i386
libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libidn2-0:i386 libllvm12:i386 libnvidia-cfg1-470 libnvidia-common-470
libnvidia-compute-470 libnvidia-compute-470:i386 libnvidia-decode-470 libnvidia-decode-470:i386 libnvidia-encode-470 libnvidia-encode-470:i386
Finally restart the system using reboot
or init 6
command as shown below.
root@cyberithub:~# init 6
c) Using NVIDIA File
Lastly, you can also install the NVIDIA drivers manually by downloading the drivers manual from official website. You need to first check the driver needed by the devices using same ubuntu-drivers devices
command.
root@cyberithub:~# ubuntu-drivers devices
Then according to the recommendation you can go to Official website and download the driver using wget
utility as shown below.
root@cyberithub:~# wget https://us.download.nvidia.com/XFree86/Linux-x86_64/510.60.02/NVIDIA-Linux-x86_64-510.60.02.run
--2022-04-14 21:40:54-- https://us.download.nvidia.com/XFree86/Linux-x86_64/510.60.02/NVIDIA-Linux-x86_64-510.60.02.run
Resolving us.download.nvidia.com (us.download.nvidia.com)... 2606:2800:247:2063:46e:21d:825:102e, 192.229.232.112
Connecting to us.download.nvidia.com (us.download.nvidia.com)|2606:2800:247:2063:46e:21d:825:102e|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 328284028 (313M) [application/octet-stream]
Saving to: ‘NVIDIA-Linux-x86_64-510.60.02.run’
NVIDIA-Linux-x86_64-510.60.02.run 100%[============================================================================>] 313.08M 8.12MB/s in 36s
2022-04-14 21:41:31 (8.60 MB/s) - ‘NVIDIA-Linux-x86_64-510.60.02.run’ saved [328284028/328284028]
Next step is to install the prerequisites which will be required by the driver for successful installation. This can be done by using below apt install
command.
root@cyberithub:~# apt install build-essential libglvnd-dev pkg-config
Reading package lists... Done
Building dependency tree
Reading state information... Done
pkg-config is already the newest version (0.29.1-0ubuntu4).
pkg-config set to manually installed.
build-essential is already the newest version (12.8ubuntu1.1).
build-essential set to manually installed.
The following additional packages will be installed:
libegl-dev libgl-dev libgles-dev libgles1 libglx-dev libopengl-dev
The following NEW packages will be installed:
libegl-dev libgl-dev libgles-dev libgles1 libglvnd-dev libglx-dev libopengl-dev
0 upgraded, 7 newly installed, 0 to remove and 183 not upgraded.
Need to get 202 kB of archives.
After this operation, 2,482 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Also before installing the driver, it is mandatory to stop your current display server by changing the run level to 3. The best way to change the run level is through telinit
command.
root@cyberithub:~# telinit 3
Once the Display Manager is disabled, you can now install the driver by running below command.
root@cyberithub:~# bash NVIDIA-Linux-x86_64-510.60.02.run
Verifying archive integrity... OK
Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 510.60.02................
After successful installation of driver, you can restart run level 6 by using init 6
command. This will reboot your system and start it with display server on.
root@cyberithub:~# init 6
Step 5: Uninstall NVIDIA driver
Depending on how you have installed the driver, you can use below method to uninstall it.
a) When installed through Ubuntu Repo
If you have installed the driver from Ubuntu Repo then use below command to uninstall it. Finally, reboot the system with init 6
or reboot
command.
root@cyberithub:~# apt remove nvidia-driver-470 Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: dctrl-tools dkms libatomic1:i386 libbsd0:i386 libdrm-amdgpu1:i386 libdrm-intel1:i386 libdrm-nouveau2:i386 libdrm-radeon1:i386 libdrm2:i386 libedit2:i386 libelf1:i386 libexpat1:i386 libffi7:i386 libgl1:i386 libgl1-mesa-dri:i386 libglapi-mesa:i386 libglvnd0:i386 libglx-mesa0:i386 libglx0:i386 libllvm12:i386 libnvidia-cfg1-470 libnvidia-common-470 libnvidia-compute-470:i386 libnvidia-decode-470 libnvidia-decode-470:i386 libnvidia-encode-470 libnvidia-encode-470:i386 libnvidia-extra-470 libnvidia-fbc1-470 libnvidia-fbc1-470:i386 libnvidia-gl-470 libnvidia-gl-470:i386 libnvidia-ifr1-470 libnvidia-ifr1-470:i386 libpciaccess0:i386 libsensors5:i386 libstdc++6:i386 libvdpau1 libvulkan1:i386 libwayland-client0:i386 libx11-6:i386 libx11-xcb1:i386 libxau6:i386 libxcb-dri2-0:i386 libxcb-dri3-0:i386 libxcb-glx0:i386 libxcb-present0:i386 libxcb-randr0:i386 libxcb-shm0:i386 libxcb-sync1:i386 libxcb-xfixes0:i386 libxcb1:i386 libxdmcp6:i386 libxext6:i386 libxfixes3:i386 libxnvctrl0 libxshmfence1:i386 libxxf86vm1:i386 mesa-vdpau-drivers mesa-vulkan-drivers:i386 nvidia-compute-utils-470 nvidia-dkms-470 nvidia-kernel-common-470 nvidia-kernel-source-470 nvidia-prime nvidia-settings nvidia-utils-470 screen-resolution-extra vdpau-driver-all xserver-xorg-video-nvidia-470 Use 'apt autoremove' to remove them. The following packages will be REMOVED: nvidia-driver-470 0 upgraded, 0 newly installed, 1 to remove and 21 not upgraded. After this operation, 1,559 kB disk space will be freed. Do you want to continue? [Y/n]
b) When installed manually
If you have installed the driver manually then use below command to uninstall it. Finally reboot the system with init 6
or reboot
command.
root@cyberithub:~# bash NVIDIA-Linux-x86_64-XXX.XX.run --uninstall