For Ubuntu enthusiasts, particularly gamers, selecting the optimal graphics drivers is crucial for maximizing system performance. You’re on the right path if you’re looking to install NVIDIA Drivers on Ubuntu 23.04, 22.04, or 20.04. While the default Mesa drivers are sufficient for basic tasks, NVIDIA drivers significantly boost visuals, performance, and overall user experience. In this guide, we’ll explore the differences between Mesa and NVIDIA drivers and discuss the benefits of choosing NVIDIA for your Ubuntu setup.
Distinguishing Features:
- Optimized Performance: NVIDIA drivers, tailored for NVIDIA GPUs, enhance gaming, 3D rendering, and other graphic-centric tasks. Mesa drivers, being open-source, cater to a broader spectrum of graphic hardware, which might not be as optimized for NVIDIA GPUs.
- Advanced Feature Set: NVIDIA drivers incorporate cutting-edge technologies like ray tracing, DLSS, and hardware video encoding/decoding, enriching your multimedia and gaming journey. While Mesa drivers evolve, they might not fully harness these advanced NVIDIA GPU features.
- Stability and GPU Compatibility: Directly developed by NVIDIA, these drivers promise stability, compatibility, and dedicated support for the latest GPUs. In contrast, the open-source nature of Mesa drivers might not guarantee the same degree of compatibility or support for specific NVIDIA features.
- Regular Updates: NVIDIA ensures its drivers are consistently updated, introducing new features, enhancing performance, and rectifying bugs. Although Mesa drivers receive regular updates, they might not always match NVIDIA’s improvements for its GPUs.
Given these distinctions, Ubuntu aficionados with NVIDIA GPUs, especially those passionate about gaming, should contemplate integrating NVIDIA drivers to maximize their system’s capabilities. Our forthcoming guide will elucidate the installation process for NVIDIA drivers on Ubuntu 22.04 Jammy Jellyfish and Ubuntu 20.04 Focal Fossa. While the spotlight is on these versions, the techniques mainly apply to recent short-term releases, like 23.04 and 23.10, barring the final method involving NVIDIA driver installation from the CUDA repository.
Table of Contents
Section 1: Remove Previous NVIDIA Installations on Ubuntu
If you’ve previously installed NVIDIA drivers using a specific method and wish to reinstall using a different approach mentioned here, be cautious. Mixing multiple NVIDIA repositories can disrupt your drivers. It’s recommended to revert to Mesa drivers first and then freshly install the NVIDIA drivers. If you haven’t installed any NVIDIA drivers yet, you can bypass this section.
Method 1: APT Method Removal of NVIDIA Drivers from Ubuntu
First, use a blanket command to remove any traces of NVIDIA installation on your system. This command searches for any NVIDIA-related packages and purges them from your system:
sudo apt autoremove nvidia* --purge
Method 2: Removing Runfile NVIDIA Driver Installations from Ubuntu
Suppose you have installed the NVIDIA drivers using the “.run” file method (which is not recommended due to better alternatives like the NVIDIA CUDA repository). In that case, you need to remove them using a different approach.
To remove the runfile type of installation, use the following command:
sudo /usr/bin/nvidia-uninstall
Method 3: Removing NVIDIA CUDA Toolkit Runfile Installations from Ubuntu
If you have installed the CUDA toolkit using the runfile method, you must also remove it. To do so, execute the following command:
sudo /usr/local/cuda-X.Y/bin/cuda-uninstall
Replace X.Y
with the version number of your installed CUDA toolkit.
These methods should remove any existing NVIDIA drivers from your Ubuntu system, allowing you to proceed with a fresh installation.
Section 2: Pre-installation Checks before NVIDIA Drivers Installation
Before installing the NVIDIA drivers, it is essential to perform some pre-installation checks to ensure a smooth installation process. This section will guide you through the necessary steps.
Step 1: Update Ubuntu
Updating your system ensures that all packages are up-to-date, reducing the likelihood of conflicts during the installation. This is particularly important when installing packages such as new kernels and graphics card drivers.
First, update the package list:
sudo apt update
Next, upgrade any outdated packages:
sudo apt upgrade
Step 2: Determine Your Graphics Card
For users with older NVIDIA graphics cards, it is essential to determine if your card is supported. Users with brand-new cards can skip this step, as they will undoubtedly be supported.
First, find your graphics card module using the following command:
lspci | grep -e VGA
This command will display information about your graphics card. An example output is shown below:
03:00.0 VGA compatible controller: NVIDIA Corporation TU117 [GeForce GTX 1650] (rev a1)
If you use an older card, research it on the NVIDIA website to check if the latest drivers support it. In some cases, you may need to install legacy drivers instead.
Section 3: Install NVIDIA Drivers with Ubuntu Repository using CLI
The command line is the first option for installing NVIDIA drivers on your Ubuntu system. While advanced users may prefer command-based methods, even beginners can easily follow this approach.
Step 1: Identify Your Graphics Card and Recommended Driver
Open your terminal by pressing CTRL+ALT+T
and find information about your graphics card using the following command:
ubuntu-drivers devices
Example output:
In the example output, the graphics card model is “TU117 [GeForce GTX 1650]”, and the recommended NVIDIA driver is “nvidia-driver-525-open”. Remember that your NVIDIA graphics card model may differ, so look for the recommended driver option in your output.
Step 2: Install the Recommended Driver or Choose Another Version
You can install the recommended driver package using one of the two methods below.
- If you are satisfied with the recommended version, use this command to install it automatically:
sudo ubuntu-drivers autoinstall
- If you prefer to install a specific driver version, use the appropriate command from the list below. Remember that these version numbers are examples and will change over time.
Nvidia Drivers 535.x:
sudo apt install nvidia-driver-535
Nvidia Drivers 530.x:
sudo apt install nvidia-driver-530
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
Step 3: Reboot Your System
Once the driver installation is complete, reboot your Ubuntu system by entering the following command:
reboot
After the system restarts, your NVIDIA drivers should be successfully installed and ready for use.
Section 4: Install NVIDIA Drivers with Ubuntu Repository using GUI
The second solution for installing NVIDIA drivers on your Ubuntu system is using the graphical user interface (GUI) method. This approach is especially recommended for beginners in Linux.
Step 1: Open “Additional Drivers” Application
First, go to your application menu and open the “Additional Drivers” application. For users new to Ubuntu, you can find it by following these steps:
- Click “Activities” in the top-left corner of the screen.
- Type “Additional Drivers” in the search bar.
- Select the “Additional Drivers” application from the search results.
Example:
Step 2: Choose the NVIDIA Driver to Install on Ubuntu
The “Software & Updates” window will appear, displaying a list of available drivers for your NVIDIA graphics card. Note that the number of drivers listed may vary depending on the age and popularity of your graphics card.
Select the NVIDIA driver you wish to install and click the “Apply Changes” button. The installation process will take around 2 to 3 minutes, depending on your system and its resources.
Example:
Step 3: Reboot Your System
Once the driver installation is complete, reboot your system. You can do this immediately by typing the following command in your terminal:
reboot
Section 5: Install NVIDIA Drivers using graphics-drivers/ppa
The following method involves installing NVIDIA drivers from the graphics-drivers/ppa
repository, which is known for providing the most up-to-date proprietary NVIDIA drivers. This approach is recommended for users who want to update their graphics drivers regularly.
Step 1: Install Required Dependencies
First, you need to install the required dependencies by executing the following command:
sudo apt install software-properties-common -y
Step 2: Add the graphics-drivers PPA on Ubuntu
Next, add the graphics-drivers/ppa
repository to your system using the following command:
sudo add-apt-repository ppa:graphics-drivers/ppa -y
Step 3: Update Package List
With the PPA now added to your system, update the package list by running:
sudo apt update
Step 4: Check Recommended Drivers
Now, enter the following command to display the recommended drivers for your graphics card:
ubuntu-drivers devices
The output will differ from the one you received using the standard Ubuntu APT repository. You will see a third-party recommended driver in the list.
Step 5: Install the NVIDIA Driver
To install the driver, choose one of the following options:
- If you are satisfied with the recommended version, use this command:
sudo ubuntu-drivers autoinstall
- Alternatively, if you want to install a specific driver version, use one of the commands below:
Nvidia Drivers 535.x:
sudo apt install nvidia-driver-535
Nvidia Drivers 530.x:
sudo apt install nvidia-driver-530
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
Step 6: Reboot Your System
Once the installation is complete, reboot your system using the following command:
reboot
After the restart, the newly installed NVIDIA drivers from the graphics-drivers/ppa
repository will be active on your system.
Section 6: Install NVIDIA Drivers from CUDA Repository
Note: This section only applies to Ubuntu 22.04 and 20.04 LTS releases. Short-term releases cannot use this method.
The last method of installing NVIDIA drivers involves using the NVIDIA CUDA repository, which is frequently updated and supports Debian, Ubuntu, RHEL, and other popular Linux distributions.
Step 1: Install the Required Packages
First, make sure to install the following packages, which might already be installed on your system:
sudo apt install dirmngr ca-certificates software-properties-common apt-transport-https dkms curl -y
Step 2: Import NVIDIA Repository GPG Key on Ubuntu
Next, import the GPG key for 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
Step 3: Add NVIDIA Repository
Now, add the NVIDIA repository for your system, ensuring 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
Step 4: Update Package List
Update your sources list to reflect the newly added repository:
sudo apt update
Step 5: Search and Install NVIDIA Drivers on Ubuntu VIA NVIDIA PPA
Next, install the latest NVIDIA drivers. You can use the APT search command to view the complete list of available drivers:
apt search nvidia-driver-*
This tutorial demonstrates how to install the latest version currently available. Replace 535 with 530, 525, 520, 515, etc., depending on your preference.
For the best compatibility, install the proprietary version, especially if you are new to Ubuntu. Open-source drivers may cause issues with certain graphics cards.
Advanced users can easily switch between open-source and proprietary drivers as needed.
- Install NVIDIA Drivers 535.xx without CUDA support (proprietary):
sudo apt install nvidia-driver-525
- Install NVIDIA Drivers 535.xx with CUDA support (proprietary):
sudo apt install nvidia-driver cuda
- Install NVIDIA Drivers 535.xx without CUDA support (open-source):
sudo apt install nvidia-driver-535-open
- Install NVIDIA Drivers 535.xx with CUDA support (open-source):
sudo apt install nvidia-driver-535-open cuda
If the above drivers do not work, you can try using version 530, 520, 515, etc., or use the search command mentioned earlier to find other versions.
Step 6: Install Headless Drivers
It’s often best to install NVIDIA drivers directly from the CUDA repository for non-desktop users and those running servers with specialized software. The instructions are the same as for desktop users, but you need to add “headless” to the command.
- Example: Proprietary NVIDIA 535 headless drivers
sudo apt install nvidia-headless-535
- Example: Open-source NVIDIA 525 headless drivers
sudo apt install nvidia-headless-535-open
For more options, use the APT search command in your terminal to locate specific packages:
apt search nvidia-headless*
Additionally, you can add CUDA and any other required packages. Desktop users should not install headless drivers.
Section 7: Confirming Nvidia Drivers Installation
Once you have successfully installed the Nvidia drivers and rebooted your system, verifying that the installation was successful is essential. In this section, we will guide you on confirming the installation using the command line and the graphical user interface (GUI).
Step 1: Check Nvidia Drivers via Terminal on Ubuntu
You can use the command to verify the installation through the command line. This command will display information about your Nvidia GPU, such as the driver version, GPU usage, temperature, and more.
nvidia-smi
Example output:
Step 2: Access Nvidia Settings GUI on Ubuntu
You can launch the Nvidia settings GUI if you prefer a graphical interface. To do this, follow the steps below:
- Open the terminal and enter the following command:
nvidia-settings
- Alternatively, you can access the Nvidia settings through the application menu:
- Go to Activities > Show Applications > NVIDIA X Server Settings.
Example:
After opening the Nvidia settings GUI, you can see your GPU’s configuration, information, and other settings that can be customized.
Example:
Conclusion: Installing Nvidia Drivers on Ubuntu
Installing Nvidia drivers on Ubuntu is straightforward, enabling you to take full advantage of your GPU’s capabilities. Following the methods outlined in this guide, you can successfully install the drivers and configure your system for optimal performance. Whether you prefer the terminal or graphical user interface, Ubuntu offers multiple options to suit your preferences. Always choose the appropriate driver version for your GPU and keep it up-to-date to ensure a smooth and efficient computing experience.