Sunday, May 10, 2020

Ubuntu 20.04 LTS: How to Install Nvidia Driver on Ubuntu 20.04

How to Install Nvidia Driver on Ubuntu 20.04

As Linux getting more user friendly, game developers are adding more support thanks to Steam. The performance of graphics processing units (GPUs) mainly depends on drivers. Ubuntu by default use open source video driver Nouveau which has limited support and features when compared with proprietary Nvidia drivers.
The proprietary Nvidia driver is essential to Ubuntu users looking to play games. However, if you are a basic user, there is no need to have this driver installed, as the open-source one works just fine.
In this tutorial, we are going to learn different ways to install Nvidia drivers on Ubuntu 20.04 LTS.

Check hardware Information of GPU

Before installing Nvidia drivers on Ubuntu, ensure that you have Nvidia GPU in your system. There are lots of commands available to get Linux hardware details.
To confirm this, simply run the following hwinfo command.
$ sudo hwinfo  --gfxcard --short
Install NVIDIA driver on Ubuntu 20.0420.04
You can check which card is being used by the prime-select command:
$ sudo prime-select query

prime-select query
The lshw command can display hardware and driver details of the currently used Nvidia card.
$ sudo lshw -c display | grep NVIDIA
Display NVIDIA driver only
The lspci command is another option to get the GPU hardware details.
$ sudo lspci -nnk | grep -iA3 vga
or
$ sudo lspci | grep -i --color 'vga\|3d\|2d'
If you have installed inxi tool, run the following command.
$ sudo inxi -Gx

Install Nvidia drivers using from GUI

Lets first check how to install Nvidia driver from the graphical user interface. On the main menu, type "software update manager" and click on it to open.
software and update manager
On the software updater pop-up, click on the 'Settings & Livepatch' button as shown.
software updater
This will launch the 'Software and Updates' window as shown below:
Install Nvidia driver on Ubuntu 20.04
At the top-most section of the  'Software and updates' windows, be sure to find a couple of options displayed which include Ubuntu software, other software, updates e.t.c. In this case,  click on Additional Drivers, you can see there, the 'Nvidia - driver -435' (proprietary, tested) is set up as default driver used for Nvidia card, along with some proprietary divers listed.
Both, 'Nvidia - drivers 430' (proprietary) and 'Nvidia - drivers 390' (proprietary) are available for GeForce GTX 1080 Ti card. Select the first option to install Nvidia driver 430.  When you are done, click on the Apply changes button to install the driver.
Then wait for the download to complete from the internet and click on the close button.
Reboot your computer for the changes to take effect. Run the following to reboot your PC.
$ sudo shutdown -r now
or
$ sudo reboot

Install Nvidia driver from the command line (CLI)

Then, run the following commands to check the list of driver devices available for the Nvidia card from the default Ubuntu repository.
$ sudo Ubuntu-drivers devices
sudo ubuntu-drivers devices
There are four Nvidia drivers available for the GeForce MX130 model. They include the Nvidia driver -440 non-free (which is recommended for Ubuntu system), Nvidia driver -435, and -390 distro non-free and the nouveau distro free builtin open source video driver (default). Now you can run the following commands to install the specific driver you want.
$ sudo ubuntu-drivers autoinstall
Ubuntu drivers autoinstall
$ sudo apt install nvidia-driver-390
Install NVIDIA driver on Ubuntu 20.04
After the Nvidia diver has been installed, we have to reboot the computer in order to allow Nvidia prime (which is the technology) to switch in between the Intel Graphics and the Nvidia Graphics card.
$ sudo shutdown -r now

Verify using nvidia-smi

The nvidia-smi command line is a utility that is used for providing monitor and management capabilities for each and every devices i.e Nvidia Tesla, GRID, Quadro, and GeForce from Fermi and other higher architect families. Open the Terminal application and run the following command to see the Graphics Processing Unit and the process that is using the Nvidia GPU.
$ nvidia-smi
NVIDIA - smi

Configure the Nvidia Graphics driver

On the Nvidia settings command, start a Graphics User Interface(GUI)  tool for configuration of Nvidia Graphics driver. This enables you to have a glance at all the GPU information and even to configure, numerous external monitors that are connected to your system. Run the command below to launch the 'Nvidia and Server Settings' window.
$ sudo nvidia-settings
NVIDIA X server settings

How to uninstall the proprietary Nvidia driver

From open forums I have noticed many users end up issues with removing Nvidia drivers and reinstalling. Lets me share the steps I have followed to successfully uninstall the Nvidia driver and switch to the nouveau driver.
Step 1: Run the following commands to uninstall the proprietary Nvidia driver.
$ sudo dpkg -p $(dpkg -l | grep nvidia-driver | awk '{print $2}')
$ sudo apt autoremove
or
$ sudo apt purge nvidia-*
Step 2: Run these commands to switch back to the nouveau driver.
$ sudo apt install xserver-xorg-video-nouveau
Rather, you can also choose to switch to the nouveau driver just right from the Graphic User Interface. On the Software and update application, select the Additional drivers. Then, choose the nouveau display driver and then click on Apply changes.
Step 3: After that, reboot your system.
$ sudo shutdown -r now
Step 4: After your system has rebooted, run the following command to confirm the nouveau modules that have loaded.
$ lsmod | grep nouveau

Conclusion

In this tutorial, we have covered two ways that you can use to install Nvidia drivers on Ubuntu 20.04 LTS.
With that said, Nvidia is bringing Vulkan which is intended to offer higher performance and more balanced CPU/GPU usage driver to Linux,  a replacement for OpenGL.
In recent years Redhat developers are adding extra code to Nouveau improve opensource code to make it much better, let's hope the near future we could use it for the modern game.