The Nvidia Graphics Card Drivers can often improve the performance of Ubuntu systems and often improve performance for gaming or digital editing. In the following tutorial, you will learn how to install NVIDIA Graphic Drivers on 22.04 Jammy Jellyfish LTS or 20.04 Focal Fossa using four methods that should suit most user requirements.
Note about the Tutorial
The open-source drivers seem to be causing conflicts amongst many distributions depending on your new and older graphics card, especially around 525. Unless you are a strict open-source person, I suggest using the proprietary version.
Secondly, the tutorials are focused on LTS releases. The same methods will work on Ubuntu short-term releases, except for the Nvidia Repository method, which is why I left it last. Most users should use method 1 or 2 before moving on to third-party repositories.
Thirdly, things go smoothly when installing graphic drivers using these methods for most users. However, given so many variations of hardware and other conditions on a specific system, such as other graphically installed dependencies that can conflict with Nvidia drivers after being installed or during, I cannot guarantee this will work for every user, especially legacy Nvidia cards which the majority of users do not use luckily.
Now that is out of the way, let’s dive in.
Recommended Steps Before Installation
Before proceeding with the tutorial, it is highly advised to run an update in your terminal to ensure all packages are up-to-date to avoid any conflicts during the installation. This is important when installing packages such as new kernels and graphic card drivers, especially.
sudo apt update
Optionally, you can list the updates for users who require review or are curious.
sudo apt --list upgradable
Proceed to upgrade any outdated packages using the following command.
sudo apt upgrade
Previous Nvidia Installations
Please note installing Nvidia drivers over the standard packages can result in unexpected issues, especially if you install the Nvidia drivers from the default repository, then import the Nvidia Cuda repository and try to re-install or upgrade directly over those packages. If you use one method, stick to it, and if you want to swap, ensure you remove the previous installation to avoid conflicts.
Below I will briefly go through some options for removing the previous Nvidia Drivers.
First, use a blanket command to remove any traces of Nvidia installation on your system.
sudo apt autoremove nvidia* --purge
The second method is for anyone that installed the Nvidia drivers using the “.run” file, a method I use suggest as an installation method but is shared amongst other Linux blogs. Given the alternatives using the Nvidia Cuda repository, I recommend using this over runfile installations.
To remove the runfile type of installation, use the following command.
sudo /usr/bin/nvidia-uninstall
Lastly, remove the CUDA toolkit runfile installation using the following command.
sudo /usr/local/cuda-X.Y/bin/cuda-uninstall
These few methods may remove the Nvidia Drivers.
Determine your Graphics Card
The next step for users with aging NVIDIA Graphics cards is to determine what it is and if it is supported, users with brand new cards can skip this part as there is no doubt they will be supported.
First, find your graphics card module.
lspci | grep -e VGA
Example output:
03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)
If you are using an old card, I advise you to research it on the NVIDIA website; if the latest NVIDIA drivers still support it, you may need to install legacy drivers.
Method 1: Ubuntu Repository with (CLI)
The first option is to install NVIDIA drivers for your system using the command line. Advanced users prefer Nvidiacommand-based commands, but the beginner can quickly achieve this with the following.
Open your terminal “CTRL+ALT+T“ and find the information on your graphics card first.
ubuntu-drivers devices
From the example output, you can see our operating system module is “TU117 [GeForce GTX 1650]“, and the recommended Nvidia driver is “Nvidia-driver-510″. Remember, this is just an example. Everyone will have different Nivida graphic cards, and look for the recommended option if there is one.
Next, we will install the “nvidia-driver-510“ driver package. This can be done in two ways.
Second, specify below if you want to install the driver package directly or choose another version. Below are some of the newest to oldest, and anything below Nvidia is considered legacy at this point.
First, if you are happy with the recommended version, use this command:
sudo ubuntu-drivers autoinstall
Second, specify below if you want to install the driver package directly or choose another version.
Remember, these version numbers will change over time; these are just examples.
Nvidia Drivers 525.x:
sudo apt install nvidia-driver-525
Nvidia Drivers 520.x:
sudo apt install nvidia-driver-520
Nvidia Drivers 515.x:
sudo apt install nvidia-driver-515
Nvidia Drivers 510.x:
sudo apt install nvidia-driver-510
Once installed, you must reboot your Ubuntu operating system and enter the following command.
reboot
Method 2: Ubuntu Repository with GUI
The second solution in installing your Nvidia Drivers is to use the GUI method. This is recommended for beginners in Linux, especially.
Firstly, go to your application menu and open up “Additional Drivers“ as per the below example.
The full path for users new to Linux and Ubuntu is as follows.
Activities (left-hand corner) > Search bar > Additional Drivers.
Next, the “Software & Updates“ window will appear, where you can see all the available drivers for your Nvidia graphics card to install. Note that some users will see different list sizes depending on the age and popularity of the graphics card.
The next step is to select the Nvidia diver you want to install and click the “Apply Changes“ button.
Note that the installation will take 2 to 3 minutes, depending on your system and its resources.
Once installed, reboot your desktop, which can be done immediately if you would like by typing the following command in your terminal.
reboot
Method 3 – LaunchPAD PPA (graphics-drivers/ppa)
The following repository to install NVIDIA drivers is a PPA known for having the most up-to-date NVIDIA proprietary drivers available. This is recommended for users wishing to update their cards regularly.
First, install the required dependencies.
sudo apt install software-properties-common -y
Next, add the PPA
sudo add-apt-repository ppa:graphics-drivers/ppa -y
With the PPA now imported, run an APT update.
sudo apt update
Next, type in the terminal command to bring up recommendations on your graphics card.
ubuntu-drivers devices
You will get a new output compared to the original device’s printout using the standard Ubuntu APT repository.
As you can see, we now have a third-party recommended driver. To install, follow the command options again.
First, if you are happy with the recommended version, use this command:
sudo ubuntu-drivers autoinstall
Second, specify below if you want to install the driver package directly or choose another version.
Nvidia Drivers 525.x:
sudo apt install nvidia-driver-525
Nvidia Drivers 520.x:
sudo apt install nvidia-driver-520
Nvidia Drivers 515.x:
sudo apt install nvidia-driver-515
Nvidia Drivers 510.x:
sudo apt install nvidia-driver-510
Nvidia Drivers 470.x:
sudo apt install nvidia-driver-470
Nvidia Drivers 450.x:
sudo apt install nvidia-driver-450
Nvidia Drivers 390.x:
sudo apt install nvidia-driver-390
Once done, reboot.
reboot
Method 4: Nvidia CUDA repository
The third and last method of installing Nvidia drivers is utilizing the Nvidia CUDA repository. This is frequently updated and has supported Debian, Ubuntu, RHEL, and the most popular Linux distributions.
Please note that these methods only work currently for LTS versions as Nvidia are slow on the short-term release repository builds sorry to say.
Importing Nvidia Repository
First, ensure you install the following packages, which may be already installed.
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl -y
Next, import the GPG key, and ensure you match the import to your distribution version.
Import GPG key for Ubuntu 22.04 Jammy Jellyfish release:
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
Import GPG key for Ubuntu 20.04 Focal Fossa release:
curl -fSsL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/3bf863cc.pub | sudo gpg --dearmor | sudo tee /usr/share/keyrings/nvidia-drivers.gpg > /dev/null 2>&1
Second, import the repository for your system, and again ensure you import the correct one to match your Ubuntu distribution version.
Import Nvidia Repository for Ubuntu 22.04 Jammy Jellyfish release:
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
Import Nvidia Repository for Ubuntu 20.04 Focal Fossa release:
echo 'deb [signed-by=/usr/share/keyrings/nvidia-drivers.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /' | sudo tee /etc/apt/sources.list.d/nvidia-drivers.list
Install Nvidia Drivers – Proprietary or Opensource options
Update your sources list to reflect the newly added repository.
sudo apt update
Next, install the latest NVIDIA drivers. Most users should know the version they would prefer. You can also use the APT search command to bring up the complete list if you want to investigate what is available.
apt search nvidia-driver-*
The tutorial will demonstrate how to install the latest version currently available at this time. It should be pretty straightforward after presenting the following. All you would do is replace 525 with 520, 515, etc.
Remember, install the non-opensource version for the best compatibility, especially for newer users of Ubuntu. I know open-source fans will be upset at me for saying this, but I get many messages on open-source drivers with certain cards. Soon as the user installs the proprietary drivers, everything works like a charm.
For advanced users that want to use open-source, you can easily install the open-source and remove then re-install the proprietary drivers; this should be pretty easy for you.
Install NVIDIA Drivers 525.xx Without Cuda Support (Proprietary):
sudo apt install nvidia-driver-525
Install NVIDIA Drivers 525.xx With Cuda Support (Proprietary):
sudo apt install nvidia-driver cuda
Install NVIDIA Drivers 525.xx Without Cuda Support (Opensource):
sudo apt install nvidia-driver-525-open
Install NVIDIA Drivers 525.xx With Cuda Support (Opensource):
sudo apt install nvidia-driver-525-open cuda
If the above drivers do not work, just drop to 520, 515 etc or use the search command as mentioned earlier.
Install Headless Drivers
For non-desktop users and users behind servers running specialized software, often installing the Nvidia drivers directly from the CUDA repository is best for this use case. The instructions are the same as for desktop, instead you just add on headless to the command.
Example Proprietary Nvidia 525 headless drivers.
sudo apt install nvidia-headless-525
Another one with open-source Nvidia 525 headless drivers.
sudo apt install nvidia-headless-525-open
For more options, use the APT search in your terminal to locate specific packages, etc.
apt search nvidia-headless*
Additionally, add on CUDA and whatever else you require. Desktop users do not install headless.
Confirm Nvidia Drivers are Installed
Now that you have your Nvidia Drivers installed and your system has been restarted, you can verify your installation; you can use the command line terminal with the “nvidia-smi” command.
nvidia-smi
Alternatively, launch the NVIDIA settings GUI.
nvidia-settings
Or use the following path Activities > Show Applications > NVIDIA X Server Settings.
Once open, you can see your NVIDIA card configuration, information, and much more.
Comments
The tutorial taught you how to install NVIDIA Graphic Drivers on Ubuntu Linux using the GUI, the LaunchPAD Graphics proprietary drivers PPA or the Nvidia CUDA repository. Overall, using the NVIDIA drivers can be more beneficial for performance. Still, if your system works fine and has an old card, often, even after installing these drivers, you will not see much difference compared to brand-new cards or ones created in the past several years.