└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # NVIDIA Ubuntu Driver Guide 2 | A little guide to help you install & manage the NVIDIA GPU driver on your Ubuntu system(s) 3 | 4 | When I wrote this guide, I was personally using **Ubuntu 24.04.1**, 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+]`) 5 | 6 | ## Index of content 7 | - [Driver installation](#driver-installation) 8 | * ⭐ [Through the graphics-drivers PPA repository](#-installing-through-the-graphics-drivers-ppa-repository-recommended) [RECOMMENDED] 9 | * [Through the official NVIDIA installer from the Nvidia.com website](#installing-through-the-official-nvidia-installer-from-the-nvidiacom-website) 10 | - [Driver uninstallation](#driver-uninstallation) 11 | * [When installed through the graphics-drivers PPA repository](#uninstalling-the-driver-when-installed-through-the-graphics-drivers-ppa-repository) 12 | * [When installed through the official NVIDIA installer from the Nvidia.com website](#uninstalling-the-driver-when-installed-through-the-official-nvidia-installer-from-the-nvidiacom-website) 13 | - [Issues faced after installing the NVIDIA drivers, and how to solve them](#issues-faced-after-installing-the-nvidia-drivers-and-how-to-solve-them) 14 | * [Fix ghost "Unknown Display" issue](#theres-a-ghost-unknown-display-on-the-gnome-displays-settings-especially-if-you-followed-the-graphics-drivers-ppa-repository-installation-procedure) 15 | * [Wayland is no longer enabled/not visible on the login screen](#wayland-is-not-shown-as-an-option-on-the-login-screen-or-the-cog-icon-of-the-login-screen-doesnt-show-at-all) 16 | * [Fix Wayland issues (flickering, etc.)](#the-experience-on-wayland-is-not-the-smoothest-fix-wayland-issues) 17 | - [References](#references) 18 | 19 | ----- 20 | 21 | > ## ⚠️ Warning 22 | > 23 | > Please follow & read every part of this guide with fine care to avoid the occurrence of any problems. 24 | > 25 | > 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. 26 | 27 | ## Driver installation 28 | 29 | ### ⭐ Installing through the `graphics-drivers` PPA repository [RECOMMENDED] 30 | 31 | 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). 32 | 33 | 1. Ensure that you have uninstalled any previously installed NVIDIA drivers: 34 | * to uninstall any Nvidia drivers installed from an APT repository: 35 | ``` 36 | sudo apt-get remove --purge '^nvidia-.*' 37 | sudo apt autoremove 38 | sudo apt install ubuntu-drivers-common -y 39 | reboot 40 | ``` 41 | * to uninstall any Nvidia drivers installed using the official NVIDIA installer (`.run` file): [Driver uninstallation](#uninstalling-the-driver-when-installed-through-the-official-nvidia-installer-from-the-nvidiacom-website) 42 | 43 | 2. Install these dependencies to ensure DKMS support and a problem-free installation process: 44 | ``` 45 | 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 46 | ``` 47 | 48 | 3. Add the repository and install the driver: 49 | ``` 50 | sudo add-apt-repository ppa:graphics-drivers/ppa 51 | sudo apt update 52 | sudo apt install nvidia-driver-570 53 | reboot 54 | ``` 55 | 56 | NOTE: At the time this guide was last updated, 570 is the latest tested version of the driver available on the repository. 57 | 58 | Navigate to https://launchpad.net/~graphics-drivers/+archive/ubuntu/ppa to check what the latest version of the driver is, then replace the `driver-570` part with the version you would like to install. 59 | 60 | 4. Once the system has rebooted, run `nvidia-smi` to confirm that the driver has been installed with no issues. 61 | 62 | ### Installing through the official NVIDIA installer from the Nvidia.com website 63 | 64 | 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 :) 65 | 66 | 1. Ensure that you have uninstalled any previously installed NVIDIA drivers: 67 | * to uninstall any Nvidia drivers installed from an APT repository: 68 | ``` 69 | sudo apt-get remove --purge '^nvidia-.*' 70 | sudo apt purge libnvidia-* 71 | sudo apt autoremove 72 | sudo apt install ubuntu-drivers-common -y 73 | reboot 74 | ``` 75 | * to uninstall any Nvidia drivers installed using the official NVIDIA installer (`.run` file): [Driver uninstallation](#uninstalling-the-driver-when-installed-through-the-official-nvidia-installer-from-the-nvidiacom-website) 76 | 77 | 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 78 | ``` 79 | sudo apt remove libnvidia-egl-wayland1 80 | ``` 81 | 82 | 3. Install the required dependencies: 83 | ``` 84 | 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 85 | ``` 86 | 87 | 4. 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. 88 | 89 | 5. 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) 90 | 91 | 6. Stop the GDM service: 92 | ``` 93 | sudo systemctl stop gdm 94 | sudo systemctl stop gdm3 95 | ``` 96 | If this fails for you, try `sudo systemctl stop lightdm` instead. 97 | 98 | **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. 99 | 100 | 7. Change to the path of the directory that includes the downloaded `.run` file using `cd` 101 | 102 | 8. Run the installer: 103 | ``` 104 | chmod +x NVIDIA-Linux-x86_64-555.42.02.run 105 | sudo sh ./NVIDIA-Linux-x86_64-555.42.02.run 106 | ``` 107 | (make sure to replace the file name with the actual one that you got from the Nvidia website) 108 | 109 | 9. 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. 110 | 111 | 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. 112 | 113 | 10. Once the installer has completed installing the driver, run `sudo update-initramfs -u` to update the initramfs. 114 | 11. Edit `/etc/default/grub` using `sudo nano /etc/default/grub` 115 | 12. 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"`) 116 | 13. Run `sudo update-grub` 117 | 14. Reboot the system 118 | 15. Your newly installed driver should be up and running once the system boots up (you may run `nvidia-smi` to confirm so). 119 | 120 | ----- 121 | 122 | ## Driver uninstallation 123 | 124 | ### Uninstalling the driver when installed through the `graphics-drivers` PPA repository 125 | 126 | Run: 127 | ``` 128 | sudo apt-get remove --purge '^nvidia-.*' 129 | sudo apt autoremove 130 | sudo apt install ubuntu-drivers-common -y 131 | reboot 132 | ``` 133 | 134 | ### Uninstalling the driver when installed through the official NVIDIA installer from the Nvidia.com website 135 | 136 | 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: 137 | ``` 138 | sudo rm -rf /lib/modprobe.d/nvidia-installer-* 139 | sudo rm -rf /etc/modprobe.d/nvidia-installer-* 140 | sudo rm -rf /usr/lib/modprobe.d/nvidia-installer-* 141 | ``` 142 | 2. Remove any entries related to the NVIDIA driver (`nvidia-drm.modeset`, `nvidia-drm.fbdev`, etc) from your `/etc/default/grub` file. (__this is important__). 143 | 3. Rebuild the GRUB configuration using `sudo update-grub` 144 | 4. Run the uninstaller: 145 | ``` 146 | sudo nvidia-installer --uninstall 147 | ``` 148 | 5. Rebuild the system initramfs: 149 | ``` 150 | sudo update-initramfs -u 151 | ``` 152 | 6. Reboot the system once the uninstalling process has finished. 153 | 154 | ----- 155 | 156 | ## Issues faced after installing the NVIDIA drivers, and how to solve them 157 | 158 | ### There's a ghost "Unknown Display" on the GNOME Displays settings (especially if you followed the `graphics-drivers` PPA repository installation procedure). 159 | 160 | This seems to be a bug reported at https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-535/+bug/2063222 161 | 162 | A workaround is: 163 | ``` 164 | [ Workaround ] 165 | 166 | 1. sudo rm /dev/dri/card0 167 | 2. Log in again. 168 | ``` 169 | 170 | ### Wayland is not shown as an option on the login screen (or the cog icon of the login screen doesn't show at all) 171 | 172 | 1. Edit the `/etc/gdm3/custom.conf` file using `sudo nano /etc/gdm3/custom.conf` 173 | 2. Ensure that `WaylandEnable=true` is set in that file and make sure that it's uncommented (does not start with a `#`) 174 | 3. Run `sudo ln -s /dev/null /etc/udev/rules.d/61-gdm.rules` 175 | 4. Reboot the system 176 | 177 | ### The experience on Wayland is not the smoothest (fix Wayland issues) 178 | 179 | 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. 180 | And this has actually already gotten much better starting from the NVIDIA driver 555.42.02 which added [explicit sync](https://9to5linux.com/developer-explains-why-explicit-sync-will-finally-solve-the-nvidia-wayland-issues) support. 181 | 182 | So first of all, make sure to have: 183 | - Version 555.42.02 or a higher version of the Nvidia driver 184 | - GNOME 46.1 or a higher version on your Ubuntu installation 185 | 186 | then continue reading below to make the experience even smoother: 187 | 188 | * 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*"` 189 | 190 | In order to solve this: 191 | 192 | 1. Edit `/etc/default/grub` using `sudo nano /etc/default/grub` 193 | 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"`) 194 | 3. Run `sudo update-grub` 195 | 4. Reboot the system 196 | 197 | * 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. 198 | 199 | 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. 200 | 201 | To disable the GSP firmware, please follow the below steps: 202 | 203 | 1. Edit `/etc/default/grub` using `sudo nano /etc/default/grub` 204 | 2. Add `nvidia.NVreg_EnableGpuFirmware=0` inside your `GRUB_CMDLINE_LINUX` 205 | 3. Run `sudo update-grub` 206 | 4. Reboot the system 207 | 208 | See https://forums.developer.nvidia.com/t/major-kde-plasma-desktop-frameskip-lag-issues-on-driver-555/293606 for more information on this issue. 209 | 210 | * 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.). 211 | * 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: 212 | 1. Go to chrome://flags 213 | 2. Search "Preferred Ozone platform" 214 | 3. Set the flag to "Wayland" or "auto" 215 | 4. Restart the browser 216 | * 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 217 | 218 | * 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. 219 | 220 | 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. 221 | 222 | To enable the preserve video memory allocations module paramter, please follow the below steps: 223 | 224 | 1. Edit `/etc/default/grub` using `sudo nano /etc/default/grub` 225 | 2. Add `nvidia.NVreg_PreserveVideoMemoryAllocations=1` inside your `GRUB_CMDLINE_LINUX` 226 | 3. Run `sudo update-grub` 227 | 4. Reboot the system 228 | 5. Run `sudo cat /proc/driver/nvidia/params | grep "PreserveVideoMemoryAllocations"` to verify the parameter is now set 229 | 230 | 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](https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/powermanagement.html) to double check that the relevant `systemd` services are installed and enabled. 231 | 232 | ----- 233 | 234 | ## References 235 | - https://askubuntu.com/questions/206283/how-can-i-uninstall-a-nvidia-driver-completely/206289#206289 236 | - https://askubuntu.com/questions/1391245/getting-the-latest-nvidia-graphics-driver-through-software-updates/1391250#1391250 237 | - https://askubuntu.com/questions/271613/am-i-using-the-nouveau-driver-or-the-proprietary-nvidia-driver 238 | - https://github.com/lutris/docs/blob/master/InstallingDrivers.md 239 | - https://askubuntu.com/questions/66328/how-do-i-install-the-latest-nvidia-drivers-from-the-run-file/66335#66335 240 | - https://askubuntu.com/questions/219942/how-to-uninstall-manually-installed-nvidia-drivers/220729#220729 241 | - https://askubuntu.com/questions/1403854/cant-use-wayland-with-nvidia-510-drivers-on-ubuntu-22-04-lts 242 | - https://bbs.archlinux.org/viewtopic.php?pid=2133404#p2133404 243 | - https://wiki.archlinux.org/title/NVIDIA 244 | - https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting 245 | - https://askubuntu.com/questions/68028/how-do-i-check-if-ubuntu-is-using-my-nvidia-graphics-card/624793#624793 246 | - https://www.reddit.com/r/linux_gaming/comments/17fn30q/comment/k6bug3m/ 247 | - https://www.reddit.com/r/linux_gaming/comments/17ubgrl/nvidia_libnvidiaeglwayland1_do_i_need_to_install/ 248 | - https://www.reddit.com/r/Fedora/comments/rkzp78/make_chrome_run_on_wayland_permanently/ 249 | - https://www.reddit.com/r/Fedora/comments/1afkoge/how_to_make_vscode_run_in_wayland_mode/ 250 | - https://us.download.nvidia.com/XFree86/Linux-x86_64/555.42.02/README/installationandconfiguration.html 251 | - https://www.reddit.com/r/archlinux/comments/1cxc36m/comment/l528uff/ 252 | - https://forums.developer.nvidia.com/t/major-kde-plasma-desktop-frameskip-lag-issues-on-driver-555/293606 253 | - https://download.nvidia.com/XFree86/Linux-x86_64/510.39.01/README/gsp.html 254 | - https://download.nvidia.com/XFree86/Linux-x86_64/435.17/README/powermanagement.html 255 | - https://www.reddit.com/r/linux_gaming/comments/1bjhx8w/explicit_sync_protocol_just_merged_on_wayland/ 256 | - https://www.reddit.com/r/linux_gaming/comments/1c9izpc/gnome_461_released_with_explicit_sync/ 257 | - https://www.reddit.com/r/linux_gaming/comments/1cx8739/nvidia_555_driver_now_out_explicit_sync_support/ 258 | - https://www.tecmint.com/install-nvidia-drivers-in-linux/ 259 | - https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/ 260 | - https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/3/ 261 | --------------------------------------------------------------------------------