A little guide to help you install & manage the NVIDIA GPU driver on your Ubuntu system(s)
I am personally an Ubuntu 24.04.1 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+]
)
️ WarningPlease 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.
graphics-drivers
PPA repository [RECOMMENDED]This installation approach is the recommended one, and it actually is the method that I use to maintain an installation of the driver on my own system(s).
Ensure that you have uninstalled any previously installed NVIDIA drivers:
sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
reboot
.run
file): Driver uninstallationInstall these dependencies to ensure DKMS support and a problem-free installation process:
sudo apt install pkg-config libglvnd-dev dkms build-essential libegl-dev libegl1 libgl-dev libgl1 libgles-dev libgles1 libglvnd-core-dev libglx-dev libopengl-dev gcc make
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-driver-555
reboot
NOTE: At the time this guide was last updated, 555 is the latest tested 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.
nvidia-smi
to confirm that the driver has been installed with no issues.This procedure is more advanced and is often not recommended. However, it shall go alright as long as you follow each step with patience and care :)
Ensure that you have uninstalled any previously installed NVIDIA drivers:
sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
reboot
.run
file): Driver uninstallationEnsure 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
sudo apt install pkg-config libglvnd-dev dkms build-essential libegl-dev libegl1 libgl-dev libgl1 libgles-dev libgles1 libglvnd-core-dev libglx-dev libopengl-dev gcc make
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.
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)
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.
Change to the path of the directory that includes the downloaded .run
file using cd
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)
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 5 once the system has completed rebooting.
sudo update-initramfs -u
to update the initramfs./etc/default/grub
using sudo nano /etc/default/grub
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"
)sudo update-grub
nvidia-smi
to confirm so).graphics-drivers
PPA repositoryRun:
sudo apt-get remove --purge '^nvidia-.*'
sudo apt autoremove
reboot
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-*
nvidia-drm.modeset
, nvidia-drm.fbdev
, etc) from your /etc/default/grub
file. (this is important).sudo update-grub
sudo nvidia-installer --uninstall
sudo update-initramfs -u
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.
/etc/gdm3/custom.conf
file using sudo nano /etc/gdm3/custom.conf
WaylandEnable=true
is set in that file and make sure that it's uncommented (does not start with a #
)sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules
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:
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:
/etc/default/grub
using sudo nano /etc/default/grub
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"
)sudo update-grub
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:
/etc/default/grub
using sudo nano /etc/default/grub
nvidia.NVreg_EnableGpuFirmware=0
inside your GRUB_CMDLINE_LINUX
sudo update-grub
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. The PPA repo packages also install it by default.).
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:
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:
/etc/default/grub
using sudo nano /etc/default/grub
nvidia.NVreg_PreserveVideoMemoryAllocations=1
inside your GRUB_CMDLINE_LINUX
sudo update-grub
sudo cat /proc/driver/nvidia/params | grep "PreserveVideoMemoryAllocations"
to verify the parameter is now setIf 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.