Skip to content

A little guide to help you install & manage NVIDIA GPU drivers on your Ubuntu system

Notifications You must be signed in to change notification settings

oddmario/NVIDIA-Ubuntu-Driver-Guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 

Repository files navigation

NVIDIA Ubuntu Driver Guide

A little guide to help you install & manage the NVIDIA GPU driver on your Ubuntu system(s)

I am personally an Ubuntu 24.04 user at the moment, so this is mostly what this guide applies to (though I believe it should work alright on newer releases, and also on older releases which are not old very old [something like Ubuntu 20.04+])

Index of content


⚠️ Warning

Please follow & read every part of this guide with fine care to avoid the occurrence of any problems.

Also do not worry if the system looks stuck during any rebooting step. It actually is not stuck! Kindly allow up to 2 minutes for the rebooting to complete.

Driver installation

Installing through the graphics-drivers PPA repository

  1. Ensure that you have uninstalled any previously installed NVIDIA drivers:

    • to uninstall any Nvidia drivers installed from an APT repository:
      sudo apt-get remove --purge '^nvidia-.*'
      sudo apt autoremove
      reboot
      
    • to uninstall any Nvidia drivers installed using the official NVIDIA installer (.run file): Driver uninstallation
  2. Add the repository and install the driver:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update 
sudo apt install nvidia-driver-555
sudo reboot

NOTE: At the time this guide was last updated, 555 is the latest version of the driver available on the repository.

Navigate to https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa to check what the latest version of the driver is, then replace the driver-555 part with the version you would like to install.

  1. Once the system has rebooted, run nvidia-smi to confirm that the driver has been installed with no issues.

Installing through the official NVIDIA installer from the Nvidia.com website

This procedure is more advanced and is often not recommended. And despite so, this is actually the method that I use to maintain an installation of the driver on my own system(s). It shall go alright as long as you follow each step with patience and care :)

  1. Ensure that you have uninstalled any previously installed NVIDIA drivers:

    • to uninstall any Nvidia drivers installed from an APT repository:
      sudo apt-get remove --purge '^nvidia-.*'
      sudo apt autoremove
      reboot
      
    • to uninstall any Nvidia drivers installed using the official NVIDIA installer (.run file): Driver uninstallation
  2. Ensure that you do not have a manually installed version of libnvidia-egl-wayland1 (especially if you are going to install version 555+ of the Nvidia driver). The driver already includes it as stated @ https://us.download.nvidia.com/XFree86/Linux-x86_64/555.42.02/README/installedcomponents.html

sudo apt remove libnvidia-egl-wayland1
  1. Navigate to https://www.nvidia.com/Download/index.aspx?lang=en-us and download the proper driver for your GPU and Linux architecture. The website should give you a file that ends with the .run file extension.

NOTE: It would be lovely to store the downloaded .run file in a permanent place because you will need the exact same file if you would like to uninstall the driver later.

  1. Switch to the terminal view of your system by pressing Ctrl + Alt + F3 (if this does not switch from the GUI mode to the terminal mode for you, try Ctrl + Alt + F1 or Ctrl + Alt + F2 instead for a different tty)

  2. Stop the GDM service:

sudo systemctl stop gdm
sudo systemctl stop gdm3

If this fails for you, try sudo systemctl stop lightdm instead.

Kindly note that it is important to stop the GNOME Display Manager (GDM) service throughout the driver installation/uninstallation process as it may cause trouble otherwise.

  1. Change to the path of the directory that includes the downloaded .run file using cd

  2. Run the installer:

chmod +x NVIDIA-Linux-x86_64-555.42.02.run
sudo sh ./NVIDIA-Linux-x86_64-555.42.02.run

(make sure to replace the file name with the actual one that you got from the Nvidia website)

  1. The installer will guide you through everything. Please read everything with care and answer the prompts depending on the proper situation to avoid any problems.

NOTE: If the installer asks you to disable Nouveau, allow the installer to disable it for you. You may need to abort the installer after this, then run sudo update-initramfs -u && reboot, then start again from step 4 once the system has completed rebooting.

  1. Once the installer has completed installing the driver, run sudo update-initramfs -u to update the initramfs.
  2. Edit /etc/default/grub using sudo nano /etc/default/grub
  3. Add nvidia-drm.modeset=1 and nvidia-drm.fbdev=1 inside your GRUB_CMDLINE_LINUX (i.e. GRUB_CMDLINE_LINUX="nvidia-drm.modeset=1 nvidia-drm.fbdev=1")
  4. Run sudo update-grub
  5. Reboot the system
  6. Your newly installed driver should be up and running once the system boots up (you may run nvidia-smi to confirm so).

Driver uninstallation

Uninstalling the driver when installed through the graphics-drivers PPA repository

Run:

sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
reboot

Uninstalling the driver when installed through the official NVIDIA installer from the Nvidia.com website

  1. To ensure that we can boot into the system graphically through the Nouveau driver after uninstalling the Nvidia driver, remove any Nouveau-blacklist entries that might have been created by the installer previously:
sudo rm -rf /lib/modprobe.d/nvidia-installer-*
sudo rm -rf /etc/modprobe.d/nvidia-installer-*
sudo rm -rf /usr/lib/modprobe.d/nvidia-installer-*
sudo update-initramfs -u
  1. Remove any entries related to the NVIDIA driver (nvidia-drm.modeset, nvidia-drm.fbdev, etc) from your /etc/default/grub file. (this is important).
  2. Rebuild the GRUB configuration using sudo update-grub
  3. Reboot the system to get any NVIDIA modules unloaded
  4. Once the system boots back up, switch to the terminal view of your system by pressing Ctrl + Alt + F3 (if this does not switch from the GUI mode to the terminal mode for you, try Ctrl + Alt + F1 or Ctrl + Alt + F2 instead for a different tty)
  5. Stop the GDM service:
sudo systemctl stop gdm
sudo systemctl stop gdm3

If this fails for you, try sudo systemctl stop lightdm instead.

Kindly note that it is important to stop the GNOME Display Manager (GDM) service throughout the driver installation/uninstallation process as it may cause trouble otherwise.

  1. Change to the path of the directory that includes the downloaded .run file using cd (NOTE: Make sure its the exact same .run file that you used to install the driver)
  2. Run the uninstaller:
chmod +x NVIDIA-Linux-x86_64-555.42.02.run
sudo sh ./NVIDIA-Linux-x86_64-555.42.02.run --uninstall

(make sure to replace the file name with the actual one that you got from the Nvidia website)

NOTE: Do not panic if the screen goes blank throughout the uninstallation process. This is easily fixable by switching to the GUI tty then back to the terminal one (i.e. Ctrl + Alt + F1 then Ctrl + Alt + F3 back)

  1. Reboot the system once the uninstalling process has finished.

Issues faced after installing the NVIDIA drivers, and how to solve them

There's a ghost "Unknown Display" on the GNOME Displays settings (especially if you followed the graphics-drivers PPA repository installation procedure).

This seems to be a bug reported at https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-535/+bug/2063222

A workaround is:

[ Workaround ]

1. sudo rm /dev/dri/card0
2. Log in again.

Wayland is not shown as an option on the login screen (or the cog icon of the login screen doesn't show at all)

  1. Edit the /etc/gdm3/custom.conf file using sudo nano /etc/gdm3/custom.conf
  2. Ensure that WaylandEnable=true is set in that file and make sure that it's uncommented (does not start with a #)
  3. Run sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
  4. Reboot the system

The experience on Wayland is not the smoothest (fix Wayland issues)

This may happen for a lot of reasons. For a while now, NVIDIA has been known to have issues with the Wayland windowing system. However, NVIDIA has been working on making this better. And this has actually already gotten much better starting from the NVIDIA driver 555.42.02 which added explicit sync support.

So first of all, make sure to have:

  • Version 555.42.02 or a higher version of the Nvidia driver
  • GNOME 46.1 or a higher version on your Ubuntu installation

then continue reading below to make the experience even smoother:

  • Your system may be using the Mesa driver instead of the NVIDIA one on Wayland sessions. You can confirm this by typing glxinfo|egrep "OpenGL vendor|OpenGL renderer*"

    In order to solve this:

    1. Edit /etc/default/grub using sudo nano /etc/default/grub
    2. Add nvidia-drm.modeset=1 and nvidia-drm.fbdev=1 inside your GRUB_CMDLINE_LINUX (i.e. GRUB_CMDLINE_LINUX="nvidia-drm.modeset=1 nvidia-drm.fbdev=1")
    3. Run sudo update-grub
    4. Reboot the system
  • You may have the GSP firmware of Nvidia enabled, and this is known to cause some performance issues on the beta 555.42.02 version of the driver. Maybe this will be fixed in the future, but for now, we can disable the GSP firmware if needed.

    You can check whether the GSP firmware is enabled or no by typing nvidia-smi -q | grep "GSP Firmware" — if it says N/A then the firmware is not enabled. If otherwise (it shows a version for GSP firmware) then the firmware is enabled.

    To disable the GSP firmware, please follow the below steps:

    1. Edit /etc/default/grub using sudo nano /etc/default/grub
    2. Add nvidia.NVreg_EnableGpuFirmware=0 inside your GRUB_CMDLINE_LINUX
    3. Run sudo update-grub
    4. Reboot the system

    See https://forums.developer.nvidia.com/t/major-kde-plasma-desktop-frameskip-lag-issues-on-driver-555/293606 for more information on this issue.

  • You may be missing the libnvidia-egl-wayland1 package (which is often recommended). Try installing the package using sudo apt install libnvidia-egl-wayland1 (Please don't do this if you installed version 555+ of the Nvidia driver since the driver installer already installs it for you).

  • for Google Chrome (and Chromium-based browsers in general), you may need to switch the "Preferred Ozone platform" flag to "Wayland" or "auto". Follow the steps below in order to apply this:

    1. Go to chrome:https://flags
    2. Search "Preferred Ozone platform"
    3. Set the flag to "Wayland" or "auto"
    4. Restart the browser
  • for some Electron apps, you may need to pass the same Ozone platform flag as we did above. For example code --enable-features=UseOzonePlatform,WaylandWindowDecorations --ozone-platform-hint=auto for Visual Studio Code

  • You may not have the preserve video memory allocations module parameter enabled, and this can cause issues particularly when suspending and resuming the system, usually in the form of graphical artifacts or a broken desktop environment.

    You can check whether the module parameter is enabled or not by typing sudo cat /proc/driver/nvidia/params | grep "PreserveVideoMemoryAllocations". If the value is 0 or missing, then the parameter is not enabled.

    To enable the preserve video memory allocations module paramter, please follow the below steps:

    1. Edit /etc/default/grub using sudo nano /etc/default/grub
    2. Add nvidia.NVreg_PreserveVideoMemoryAllocations=1 inside your GRUB_CMDLINE_LINUX
    3. Run sudo update-grub
    4. Reboot the system
    5. Run sudo cat /proc/driver/nvidia/params | grep "PreserveVideoMemoryAllocations" to verify the parameter is now set

    If you are still experiencing issues with suspend/resume after enabling this module parameter, you may want to take a look at Nvidia's power management documentation to double check that the relevant systemd services are installed and enabled.


References

About

A little guide to help you install & manage NVIDIA GPU drivers on your Ubuntu system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published