Install Nvidia Drivers Ubuntu 20.04 Command Line  {3 Easy Steps}

Install Nvidia Drivers Ubuntu 20.04 Command Line {3 Easy Steps}

Ubuntu 20.04 now ranks as the top-most Linux distribution with promising safety, security, and a flourishing open-source community. Whether for gaming, machine learning, video editing, or 3D rendering, if an individual is using Nvidia hardware for any of these purposes, such drivers ought to be installed, which will help one to completely benefit from his/her system.

This article will guide the reader in steps on how to install the Nvidia driver on Ubuntu 20.04 through command-line methods. This guide might be useful for a newbie and still serve as an experienced reader into the deepest details concerning it all.

Why Do Nvidia Drivers?

Company Nvidia manufactures these drivers specifically for its own products and graphics on your PC. These comprehensive drivers, mostly superior in functionality, would typically be installed through your distribution or could be replaced by the default open-source drivers included in Ubuntu called Nouveau. They will suffice for common tasks, but they are unfortunately lacking the extra performance or flavor needed for more demanding ones, such as:

  • Video games: Driver optimization will be needed for this because it could make the difference between hundreds versus thousands in FPS and graphic fidelity.
  • Deep learning: TensorFlow and PyTorch frameworks are built on the CUDA toolkit, which Nvidia proprietary drivers support.
  • Video Editing: DaVinci Resolve works best under the Nvidia driver.
  • 3D Rendering: CUDA acceleration will help improve applications like Blender.
Nvidia Drivers

Prepping Your PC

However, before you can install Nvidia drivers, you should prepare the system for installation in the best way possible to avoid hassles later. Here’s what you would do:

Step 1: New Version of Ubuntu 20.04 

Keep your system up to date on the latest version. Open the terminal and run:


sudo apt update && sudo apt upgrade -y

This ensures that all packages and dependencies are current.

Nvidia Drivers

Step 2: Confirm Your GPU Model 

It is necessary to find out your GPU model to download the right driver relevant to your device. Use the following command:


lspci | grep -i nvidia

In the absence of the output, it might also mean that the Nvidia GPU is inactive. In addition, you can also use the lshw command:


sudo lshw -C display

With the output, it’ll tell you “Nvidia.” If your GPU isn’t visible still, check the hardware connections.

Nvidia Drivers

Step 3: Uninstall Existing Drivers

Installation problems may occur due to conflicted drivers. Remove all previously installed drivers by running: 


sudo apt remove –purge ‘^nvidia-.*’sudo apt autoremovesudo apt autoclean

So a clean place to install the new one.

Nvidia Drivers

Available Nvidia Drivers Checking

There is a utility in Ubuntu called ubuntu-drivers for listing available drivers for your GPU.

Step 1: Install the Ubuntu Driver Tool.

If not installed, one could add the tool through:


sudo apt install ubuntu-drivers-common
Nvidia Drivers

Step 2: Enumerate All Nvidia Drivers Accessible for Your GPU 

Run this command to display the list of Nvidia drivers that are available for your GPU: 


ubuntu-drivers devices

It has managed to extract a list of all drivers with their suggestions for use in your system. Output may be similar to below: 

c

driver   : nvidia-driver-525 – distro non-free recommendeddriver   : nvidia-driver-515 – distro non-freedriver   : xserver-xorg-video-nouveau – distro free

Typically, the recommended driver is the most appropriate option. 

Installing Nvidia Drivers From The Command Line On Ubuntu 20.04

There are two common methods to install Nvidia drivers: use the ubuntu-drivers tool or do it manually.

Method 1: Automatic Installation (Recommended) 

The recommended driver can be installed most easily and with maximum safety by running: 


sudo ubuntu-drivers autoinstall

This command has been pre-installed to automatically find and install the best drivers for your graphics card. Now that the installation is finished, you will need to reboot your system as:


sudo reboot

Method 2: Manual Install

If you do not intend to install the latest driver, download it from the link, and then follow the next steps:

  1. Identify the desired version of the driver (from the ubuntu-drivers devices output).
  1. Install it using the apt command. For example, to install nvidia-driver-525:
sudo apt install nvidia-driver-525
  1. Then restart the system to enable the driver:
sudo reboot
Nvidia Drivers

Verifying Driver Installation

Once installed, it is time to check whether the Nvidia driver was indeed successfully installed, and if it is currently running.

Step 1: Check Nvidia Driver Status

Run the following command:

nvidia-smi

This command will bring forth the GPU status, like the version of the driver, GPU usage, or memory utilization, to name a few examples. A successful output may resemble the following format:

mathematica


+—————————————————————————–+| NVIDIA-SMI 525.89.02   Driver Version: 525.89.02   CUDA Version: 12.0       ||——————————-+———————-+———————-+| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC || Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. ||                               |                      |               MIG M. ||===============================+======================+======================||   0  NVIDIA GeForce RTX 3060  | 00000000:01:00.0 Off |                  N/A || 30%   40C    P8     15W / 170W|      0MiB / 12053MiB |      0%      Default |+——————————-+———————-+———————-+

Seeing this means that the installation of the driver is successful and it works!

Stage 2: Check the Support of OpenGL

To check the OpenGL operations, run:

glxinfo | grep “OpenGL version”

The above command should display the version of OpenGL supported by your GPU.

Fixing all Typical Problems

While installing, sometimes there are chances of problems. Here are most of the problems and how to solve them:

Problem 1: Black Screen after Restart

The main cause behind this is the failure of the driver to match your Linux kernel with the Nvidia driver. Here is a simple solution:

  1. Boot into recovery mode. 
  1. Open up a terminal and uninstall the driver.
sudo apt remove –purge ‘^nvidia-.*’
  1. You can use an alternative version for reinstalling the driver.

Set 2: Failure Install of the Driver 

Perhaps it is a dependency that it does not have. The following could solve it for dependency issues: 

sudo apt –fix-broken install

Then it should install.

Problem 3: CUDA Tool Kit Compatibility Issues 

Check whether the version of the Nvidia driver to install would be compatible with that of the tool kit CUDA. Visit the site of Nvidia’s official page for the compatibility matrix to get the best results. 

Nvidia Drivers

Optimizing Nvidia Drivers for Performance 

You can, then, optimize the installed driver to optimize your system for performance. 

Step 1: Enable Persistence Mode 

Enable persistence mode, and the GPU would perform better in compute tasks: 

sudo nvidia-smi -pm 1

Step 2: Power Limits Adjustment

In regard to maximizing performance, you would want to set power limits:

sudo nvidia-smi -pl <value>

And replace <value> within the range of powers within your GPU with value in watts.

Step 3: Install Nvidia Settings GUI

If a graphical interface is preferred for modifying the GPU settings, install the Nvidia settings tool:

sudo apt install nvidia-settings

Run it using the

nvidia-settings

Conclusion

Installing Nvidia drivers through the command line in Ubuntu 20.04 may look to you like a very daunting task, but it is indeed possible to be done by following these steps. Poorly installed drivers are probably the number one reason why we do not maximize the usage of our Nvidia GPUs. This is true, especially for tasks such as gaming, deep learning, and rendering. 

You can either go for the automatic mode of installation or for manual installation and check validation. Then you can enjoy better performance and stability as well. Just keep in mind that troubleshooting should be done promptly for every possible issue, and you need to update your system to get the best out of it.

You can also read:

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *