You ask — we answer!

Install Nvidia drivers in Linux

There are three possible ways to install Nvidia driver in Linux (Ubuntu LTS 18.04 / 20.04 / 22.04):

  1. Automatic or manual installation via ubuntu-drivers.
  2. Manual installation via Nvidia website.
  3. Manual installation via apt package manager.

ubuntu-drivers

This package is designed specifically for Ubuntu and is capable of detecting and installing additional drivers for a range of devices, such as GPUs. To determine which devices within the system require driver installation, execute the following command:

sudo ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0 ==
    modalias : pci:v000010DEd00002684sv000019DAsd00004675bc03sc00i00
    vendor   : NVIDIA Corporation
    driver   : nvidia-driver-525 - distro non-free
    driver   : nvidia-driver-525-open - distro non-free
    driver   : nvidia-driver-525-server - distro non-free
    driver   : nvidia-driver-535 - distro non-free recommended
    driver   : nvidia-driver-535-open - distro non-free
    driver   : nvidia-driver-535-server-open - distro non-free
    driver   : nvidia-driver-535-server - distro non-free
    driver   : xserver-xorg-video-nouveau - distro free builtin

If you receive an error message ERROR:root:aplay command not found just install the missing packet or ignore it:

sudo apt install alsa-utils

To obtain more information about the driver packages available for installation on this system, please use the following command with an additional option to select only server GPUs:

sudo ubuntu-drivers list --gpgpu
nvidia-driver-525-open, (kernel modules provided by linux-modules-nvidia-525-open-generic)
    nvidia-driver-535, (kernel modules provided by linux-modules-nvidia-535-generic)
    nvidia-driver-535-open, (kernel modules provided by linux-modules-nvidia-535-open-generic)
    nvidia-driver-525-server, (kernel modules provided by linux-modules-nvidia-525-server-generic)
    nvidia-driver-525, (kernel modules provided by linux-modules-nvidia-525-generic)
    nvidia-driver-535-server-open, (kernel modules provided by linux-modules-nvidia-535-server-open-generic)
    nvidia-driver-535-server, (kernel modules provided by linux-modules-nvidia-535-server-generic)

The easiest way to automatically install all necessary drivers is to use autoinstall feature:

sudo ubuntu-drivers autoinstall

Reboot after the process is finished:

sudo shutdown -r now

You can check if the installed driver is working correctly:

sudo nvidia-smi
nvidia-smi output

You can also manually select which driver will be installed. For example:

sudo ubuntu-drivers install nvidia:535

Don’t forget to reboot the server after installation:

sudo shutdown -r now

Nvidia website

From your local PC, open the Download section on the Nvidia official website. Choose your GPU and operating system from the drop-down menus and click Search:

Nvidia driver select

Check which version of the driver is available and click the Download button:

Nvidia driver download

Also, you can download it manually from the archive section on Nvidia official website. Then, you need to upload the received file (for example, NVIDIA-Linux-x86_64-460.106.00.run) to your server using our step-by-step guide File exchange from Linux.

Before proceeding, execute the following command to install the necessary packages:

sudo apt install build-essential libglvnd-dev pkg-config

Sometimes these packages are installed in your system. Just start the driver installation:

sudo bash NVIDIA-Linux-x86_64-460.106.00.run

The last step is to reboot your server:

sudo shutdown -r now

That’s all. The Nvidia driver has been installed on your operating system.

Apt package manager

To begin, it is necessary to select the appropriate driver version for the GPUs installed on the server. Special consideration should be given to the driver branch. Usually, the driver branch is indicated by a three-digit number (for example, nvidia-driver-535). This can be determined using the command above:

sudo ubuntu-drivers devices
== /sys/devices/pci0000:00/0000:00:03.0/0000:03:00.0 ==
    modalias : pci:v000010DEd00002684sv000019DAsd00004675bc03sc00i00
    vendor   : NVIDIA Corporation
    driver   : nvidia-driver-525 - distro non-free
    driver   : nvidia-driver-525-open - distro non-free
    driver   : nvidia-driver-525-server - distro non-free
    driver   : nvidia-driver-535 - distro non-free recommended
    driver   : nvidia-driver-535-open - distro non-free
    driver   : nvidia-driver-535-server-open - distro non-free
    driver   : nvidia-driver-535-server - distro non-free
    driver   : xserver-xorg-video-nouveau - distro free builtin

We recommend installing the kernel modules first:

sudo linux-modules-nvidia-535-generic

Then, install the driver:

sudo apt install nvidia-driver-535

Finally, reboot the server:

sudo shutdown -r now

Please check that the correct kernel module has loaded and the driver is working:

sudo lsmod | grep nvidia
nvidia_uvm           1523712  0
    nvidia_drm             77824  0
    nvidia_modeset       1302528  1 nvidia_drm
    nvidia              56537088  2 nvidia_uvm,nvidia_modeset
    drm_kms_helper        311296  5 drm_vram_helper,ast,nvidia_drm
    drm                   622592  8 drm_kms_helper,drm_vram_helper,ast,nvidia,drm_ttm_helper,nvidia_drm,ttm

You can also check this by executing the Nvidia command-line utility:

sudo nvidia-smi

Uninstallation

Before changing the driver version or simply delete Nvidia driver, just input the following command:

sudo apt purge nvidia-*
sudo apt update
sudo apt autoremove

Now, you can install the needed driver.



Published: 30.04.2024


Still have questions? Write to us!

By clicking «I Accept» you confirm that you have read and accepted the website Terms and Conditions, Privacy Policy, and Moneyback Policy.