Nvidia GPUs (graphics processing units) have exceptional parallel computing potential, much higher than that of CPUs. That is why GPUs are becoming the main choice for high-performance workloads.
Aside from gaming, Nvidia GPUs are also used for 3D rendering, mining, visualization, machine learning, AI, and in data centers. For example, phoenixNAP GPU dedicated servers use Nvidia Tesla GPUs.
In this tutorial, you will learn how to install the latest proprietary Nvidia drivers on Ubuntu 20.04.
- A machine running Ubuntu 20.04
- An account with sudo/root permissions
- An Nvidia GPU
Note: Learn why and how GPUs are used for machine learning and AI in our article on GPU Machine Learning.
Install Nvidia Driver Using GUI
Ubuntu comes with open-source Nouveau drivers for Nvidia GPUs out of the box. The Nouveau driver does not harness the GPU’s full power and sometimes performs worse or even causes system instability. Nvidia proprietary drivers are much more reliable and stable.
The first way to install Nvidia drivers is by using the GUI Software & Updates app.
1. Open the Applications menu and type “software and updates.”
2. Select the Software and Updates app.
Step 2: Click the Additional Drivers Tab
Wait for the app to download a list of additional drivers available for your GPU.
The driver installed on your machine is selected by default. It is usually an open-source Nouveau display driver.
Step 3: Choose a Driver
1. From the list, select the latest Nvidia driver labeled proprietary, tested. This is the latest stable driver published by Nvidia for your GPU.
2. Click Apply Changes.
3. Enter your password and wait for the installation to finish.
Step 4: Restart
Restart the machine for the changes to take effect.
Install Nvidia Driver via Command Line
The second way to install Nvidia drivers is by using the terminal.
Step 1: Search for Nvidia Drivers
1. Open the terminal by pressing Ctrl+Alt+T or search for “terminal” in the Applications menu.
2. Run the following command:
apt search nvidia-driver
The output shows a list of available drivers for your GPU.
Step 2: Update the System Package Repository
Before installing the driver, make sure to update the package repository. Run the following commands:
sudo apt update
sudo apt upgrade
Step 3: Install the Right Driver for Your GPU
1. Choose a driver to install from the list of available GPU drivers. The best fit is the latest tested proprietary version.
2. The syntax for installing the driver is:
sudo apt install [driver_name]
For this tutorial, we installed nvidia-driver-340, the latest tested proprietary driver for this GPU.
Step 4: Reboot
Reboot your machine with the following command:
Install Nvidia Beta Drivers via PPA Repository
The PPA repository allows developers to distribute software that is not available in the official Ubuntu repositories. This means that you can install the latest beta drivers, however, at the risk of an unstable system.
To install the latest Nvidia drivers via the PPA repository, follow these steps:
Step 1: Add PPA GPU Drivers Repository to the System
1. Add the graphics drivers repository to the system with the following command:
sudo add-apt-repository ppa:graphics-drivers/ppa
2. Enter your password and hit Enter when asked if you want to add the repository.
Step 2: Identify GPU Model and Available Drivers
To verify which GPU model you are using and to see a list of available drivers, run the following command:
The output shows your GPU model as well as any available drivers for that specific GPU.
Step 3: Install Nvidia Driver
1. To install a specific driver, use the following syntax:
sudo apt install [driver_name]
For example, we installed the nvidia-340 driver version.
2. Alternatively, install the recommended driver automatically by running:
sudo ubuntu-drivers autoinstall
In this example, no changes were made as the recommended driver is already installed.
Step 4: Restart the System
Reboot the machine for the changes to take effect.
How to Uninstall Nvidia Driver
If you want to uninstall the proprietary Nvidia driver, the best option is to
remove --purge the driver.
Step 1: See Installed Packages
To check which Nvidia packages are installed on the system, run the following command:
dpkg -l | grep -i nvidia
The output returns a list of all Nvidia packages on the system.
Note: The ubuntu-desktop package could also be purged because it is a dependency of the nvidia-common package, so you may need to reinstall it if it gets removed.
Step 2: Purge Nvidia Packages
1. Run the following command:
sudo apt-get remove --purge '^nvidia-.*'
The command purges every Nvidia package from the system.
2. If the ubuntu-desktop package is removed, reinstall it with the following command:
sudo apt-get install ubuntu-desktop
Step 4: Reboot the System
Reboot your system by running
sudo reboot. By default, the system loads the open-source Nouveau driver during boot.
Note: See different ways to uninstall software in our article on How to uninstall software packages from Ubuntu.
You now know how to install proprietary Nvidia drivers on your system using the GUI app, official Ubuntu repository, or the PPA repository if you want the beta versions.
You also know how to uninstall Nvidia drivers if you want to go back to using the open-source Nouveau driver.