2024-02-20 21:16:07 +01:00
---
weight: 8
title: NVidia
---
2022-08-12 20:46:36 +02:00
2024-02-20 21:16:07 +01:00
# Foreword
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
There is no _official_ Hyprland support for Nvidia hardware. However, many people
have had success with the instructions on this page.
2024-02-20 21:16:07 +01:00
You can choose between the proprietary
[Nvidia drivers ](https://wiki.archlinux.org/title/NVIDIA ) or the open source
2024-04-21 16:35:48 +02:00
[Nouveau driver ](https://wiki.archlinux.org/title/Nouveau ). For the
2024-06-21 16:58:57 +02:00
proprietary drivers, there are 3 varieties: the current closed source driver
named 'nvidia' (or 'nvidia-dkms') which is
2024-05-11 10:32:20 +02:00
under active development; the legacy closed source drivers 'nvidia-3xxxx' for older cards
which Nvidia no longer actively supports; and the 'nvidia-open' driver which is
2024-04-20 11:59:06 +02:00
currently an alpha stage attempt to open source a part of their closed source
2024-02-20 21:16:07 +01:00
driver for newer cards.
2024-04-21 16:35:48 +02:00
If the proprietary drivers support your graphics card, it's generally recommended
2024-11-06 19:34:37 +01:00
to use them instead, as it has significantly improved performance
2024-06-21 16:58:57 +02:00
and power management for newer GPUs.
2023-09-30 20:22:09 +02:00
2024-04-20 11:59:06 +02:00
However, keep in mind that if the proprietary Nvidia drivers do not work
properly on your computer, the Nouveau driver might work fine. This will
2024-06-21 16:58:57 +02:00
likely be the case for
2024-05-11 10:32:20 +02:00
[older cards ](https://wiki.archlinux.org/title/NVIDIA#Unsupported_drivers ).
2024-04-20 11:59:06 +02:00
{{< callout > }}
2024-06-21 16:58:57 +02:00
The `nvidia-open` drivers are still not up to feature parity with the proprietary drivers.
One issue is with [suspend ](https://github.com/NVIDIA/open-gpu-kernel-modules/issues/472 ) (e.g. closing the lid on your laptop).
2024-04-20 11:59:06 +02:00
{{< / callout > }}
2024-06-21 16:58:57 +02:00
# Proprietary drivers setup
2024-06-01 20:27:10 +02:00
2024-06-21 16:58:57 +02:00
You can choose between the `nvidia` or the `nvidia-dkms` package. There are pros and cons
for each, but it is generally recommended to use the `dkms` package,
as you won't have to rebuild the initramfs [manually ](https://wiki.archlinux.org/title/NVIDIA#mkinitcpio ) every time the kernel and drivers update, for example.
2024-11-06 19:34:37 +01:00
If you're using a kernel that isn't `linux` or `linux-lts` , the `dkms` package is _required_ .
2022-08-12 20:46:36 +02:00
2024-06-21 16:58:57 +02:00
## Installation
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
Install the following packages:
2022-08-12 20:46:36 +02:00
2024-06-21 16:58:57 +02:00
1. `nvidia` or `nvidia-dkms` : The driver itself. Optionally, the open source drivers
2024-11-06 19:34:37 +01:00
from NVIDIA can be installed as `nvidia-open` or `nvidia-open-dkms` .
2024-06-21 16:58:57 +02:00
2. `nvidia-utils` : The userspace graphics drivers. You need this for running Vulkan
2024-11-06 19:34:37 +01:00
applications. If you'd like to use apps like Steam or Wine, install `lib32-nvidia-utils` as well.
2024-06-21 16:58:57 +02:00
3. `egl-wayland` (`libnvidia-egl-wayland1` and `libnvidia-egl-gbm1` on Ubuntu): This is required
2024-11-06 19:34:37 +01:00
in order to enable compatibility between the EGL API and the Wayland protocol.
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
## DRM kernel mode setting
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
Since NVIDIA does not load kernel mode setting by default, enabling it is
required to make Wayland compositors function properly. To enable it, the NVIDIA
driver modules need to be added to the initramfs.
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
Edit `/etc/mkinitcpio.conf` . In the `MODULES` array, add the following module names:
2022-08-27 23:56:52 +02:00
2024-11-06 21:55:14 +01:00
```conf {filename="/etc/mkinitcpio.conf"}
2024-06-21 16:58:57 +02:00
MODULES=(... nvidia nvidia_modeset nvidia_uvm nvidia_drm ...)
```
Then, create and edit `/etc/modprobe.d/nvidia.conf` . Add this line to the file:
2024-11-06 21:55:14 +01:00
```conf {filename="/etc/modprobe.d/nvidia.conf"}
2024-06-21 16:58:57 +02:00
options nvidia_drm modeset=1 fbdev=1
2024-04-20 11:59:06 +02:00
```
2022-08-27 23:56:52 +02:00
2024-06-21 16:58:57 +02:00
Lastly, rebuild the initramfs with `sudo mkinitcpio -P` , and reboot.
2022-08-27 23:56:52 +02:00
2024-06-21 16:58:57 +02:00
More information is available [here ](https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting ).
2023-04-22 22:26:23 +02:00
2024-06-21 16:58:57 +02:00
## Environment variables
Add these variables to your Hyprland config:
2024-02-20 21:16:07 +01:00
2024-11-06 21:55:14 +01:00
```ini
2024-04-20 11:59:06 +02:00
env = LIBVA_DRIVER_NAME,nvidia
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
2024-10-26 03:14:25 +02:00
```
2024-06-15 16:06:56 +02:00
2024-10-26 03:14:25 +02:00
and set this variable:
2024-11-06 19:34:37 +01:00
2024-10-26 03:14:25 +02:00
```ini
2024-06-15 16:06:56 +02:00
cursor {
no_hardware_cursors = true
}
2024-04-20 11:59:06 +02:00
```
2023-02-07 13:25:30 +01:00
2024-05-09 23:14:08 +02:00
{{< callout type = warning > }}
2024-04-23 12:42:45 +02:00
2024-05-09 23:14:08 +02:00
Previously used `WLR_NO_HARDWARE_CURSORS` environment variable has been deprecated.
2024-08-15 18:26:35 +02:00
Do not set it in your configs. Use `cursor:no_hardware_cursors` instead.
2024-07-21 13:11:03 +02:00
2024-10-26 03:15:11 +02:00
If you want to try hardware cursors, you can enable them by setting `cursor:no_hardware_cursors = false` ,
but it will require also enabling `cursor:allow_dumb_copy` which
may cause small to major hitches whenever the cursor shape changes. If this is a problem on your system,
2024-08-15 18:26:35 +02:00
keep hardware cursors disabled.
2024-04-23 12:42:45 +02:00
{{< / callout > }}
2024-06-21 16:58:57 +02:00
## Finishing up
2024-11-06 19:34:37 +01:00
Install a few packages to get some apps to function natively with Wayland for the
best compatibility and performance.
2024-06-21 16:58:57 +02:00
See the [the Master Tutorial ](https://wiki.hyprland.org/Getting-Started/Master-Tutorial/#force-apps-to-use-wayland ).
2024-02-20 21:16:07 +01:00
2024-04-20 11:59:06 +02:00
Reboot your computer.
Launch Hyprland.
It _should_ work now.
## VA-API hardware video acceleration
2024-06-21 16:58:57 +02:00
Hardware video acceleration on Nvidia and Wayland is possible with the
2024-04-20 11:59:06 +02:00
[nvidia-vaapi-driver ](https://github.com/elFarto/nvidia-vaapi-driver ). This may
2024-06-21 16:58:57 +02:00
solve specific issues in Electron apps.
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
The install instructions are available in the README, however, a quick guide will
2024-04-20 11:59:06 +02:00
be given here:
2024-06-21 16:58:57 +02:00
1. Install the package. On Arch, this is `libva-nvidia-driver` in the official
2024-11-06 19:34:37 +01:00
repos.
2024-02-20 21:16:07 +01:00
2024-06-21 16:58:57 +02:00
2. Add this variable to your hyprland config:
2024-11-06 21:55:14 +01:00
```ini
2024-06-21 16:58:57 +02:00
env = NVD_BACKEND,direct
```
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
See [here ](https://github.com/elFarto/nvidia-vaapi-driver?tab=readme-ov-file#upstream-regressions )
for more information on this environment variable.
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
You can check the README to get it working for Firefox.
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
## Other issues
2024-04-20 11:59:06 +02:00
### Regarding environment variables
- If you face problems with Discord windows not displaying or screen sharing not
2024-11-06 19:34:37 +01:00
working in Zoom, first try running them in Native Wayland (more details below).
Otherwise, remove or comment the line
`env = __GLX_VENDOR_LIBRARY_NAME,nvidia` .
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
### Multi-monitor with hybrid graphics
2024-04-20 11:59:06 +02:00
On a hybrid graphics device (a laptop with
2024-02-20 21:16:07 +01:00
both an Intel and an Nvidia GPU), you will need to remove the `optimus-manager`
package if installed (disabling the service does not work). You also need to
change your BIOS settings from hybrid graphics to discrete graphics.
2024-06-21 16:58:57 +02:00
### Flickering in Electron / CEF apps
2023-02-05 20:59:14 +01:00
2024-04-20 11:59:06 +02:00
This flickering is likely caused by these apps running in XWayland.
2024-06-21 16:58:57 +02:00
To fix the flickering, try running the apps in native Wayland instead.
2024-04-20 11:59:06 +02:00
For most Electron apps, you should be fine just adding this
environment variable to your config:
2022-08-12 20:46:36 +02:00
2024-11-06 21:55:14 +01:00
```ini
2024-04-20 11:59:06 +02:00
env = ELECTRON_OZONE_PLATFORM_HINT,auto
2022-08-12 20:46:36 +02:00
```
2023-02-26 12:06:16 +01:00
2024-06-21 16:58:57 +02:00
This has been confirmed to work on Vesktop, VSCodium, Obsidian and will probably
2024-04-20 11:59:06 +02:00
work on other Electron apps as well.
2024-02-20 21:16:07 +01:00
2024-04-20 11:59:06 +02:00
For other apps, including CEF apps, you will need to launch them with these flags:
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
```sh
--enable-features=UseOzonePlatform --ozone-platform=wayland
```
To do this easily for Spotify, Arch Linux has a `spotify-launcher` packages
in their official repos. You should use that instead of the `spotify`
2024-11-06 19:34:37 +01:00
package in the AUR. Then, enable the Wayland backend in
2024-04-20 11:59:06 +02:00
`/etc/spotify-launcher.conf` by uncommenting this line:
2024-11-06 21:55:14 +01:00
```sh {filename="/etc/spotify-launcher.conf"}
2024-04-20 11:59:06 +02:00
extra_arguments = ["--enable-features=UseOzonePlatform", "--ozone-platform=wayland"]
```
Some CEF / Electron apps may also have a respective flags file in ~/.config.
For example, for VSCodium, you can add the flags to `~/.config/codium-flags.conf`
and for Obsidian, you can add the flags to `~/.config/obsidian/user-flags.conf` .
2024-02-20 21:16:07 +01:00
{{< callout > }}
2024-04-20 11:59:06 +02:00
On earlier Nvidia driver versions, including 535, you may have to also include
the `--disable-gpu` and `--disable-gpu-sandbox` flags, but, as the names suggest,
you will lose hardware acceleration for whichever app is run with these flags.
2024-02-20 21:16:07 +01:00
{{< / callout > }}
2023-02-26 12:06:16 +01:00
2024-06-21 16:58:57 +02:00
For NixOS, you can set the `NIXOS_OZONE_WL` environment variable
2024-04-20 11:59:06 +02:00
to `1` , which should automatically configure Electron / CEF apps to run with native
Wayland for you.
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
While it is best to have as many things as possible running natively in
2024-06-21 16:58:57 +02:00
Wayland, the flickering will likely be solved in the 555 series of Nvidia driver updates.
### Flickering in XWayland games
2022-08-12 20:46:36 +02:00
2024-11-06 19:34:37 +01:00
XWayland games may flicker or present frames out-of-order in a way which makes them unplayable.
2024-08-06 15:52:25 +02:00
This is due to the lack of implicit synchronization in the driver, and/or flaky explicit sync support
in newer ones.
2022-08-12 20:46:36 +02:00
2024-06-21 16:58:57 +02:00
There are a few fixes:
2024-04-20 11:59:06 +02:00
2024-07-01 16:56:33 +02:00
1. Install the latest versions of `xorg-xwayland` , `wayland-protocols` and Nvidia driver.
Ensure `xorg-xwayland` is at least version 24.1, `wayland-protocols` is at least version 1.34 and Nvidia driver is at least version 555.
These enable explicit sync on the Nvidia driver and should avoid flickering.
2022-08-12 20:46:36 +02:00
2024-07-01 16:56:33 +02:00
2. If your GPU is no longer supported by the 555 driver, install older Nvidia drivers which do not exhibit this issue. The
2024-08-06 15:52:25 +02:00
last ones which would work will be the 535xx series of drivers. These
can be installed on Arch via [these AUR packages ](https://aur.archlinux.org/packages?O=0&K=535xx )
2024-06-21 16:58:57 +02:00
2024-08-06 15:52:25 +02:00
3. Try disabling explicit sync. In some select cases, explicit sync may actually cause issues due to the flaky nature of Nvidia drivers.
Set `render:explicit_sync = 0` in your hyprland config.
2022-08-13 01:47:48 +02:00
2024-04-20 11:59:06 +02:00
### Fixing other random flickering (nuclear method)
2024-04-21 16:35:48 +02:00
Note that this forces performance mode to be active, resulting in
increased power-consumption (from 22W idle on a RTX 3070TI, to 74W).
2024-04-20 11:59:06 +02:00
2024-11-06 19:34:37 +01:00
This may not be needed for some users. Only apply these 'fixes' if you
2024-04-21 16:35:48 +02:00
do notice flickering artifacts from being idle for ~5 seconds.
2022-08-12 20:46:36 +02:00
Make a new file at `/etc/modprobe.d/nvidia.conf` and paste this in:
2022-08-13 01:47:48 +02:00
2024-11-06 21:55:14 +01:00
```conf {filename="/etc/modprobe.d/nvidia.conf"}
2022-08-12 20:46:36 +02:00
options nvidia NVreg_RegistryDwords="PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3"
```
2022-08-13 01:47:48 +02:00
Reboot your computer and it should be working.
2023-09-29 22:36:22 +02:00
2024-01-30 22:18:13 +01:00
If it does not, try:
2024-02-20 21:16:07 +01:00
2024-06-21 16:58:57 +02:00
1. Lowering your monitor's refresh rate: This can stop the flickering
2024-11-06 19:34:37 +01:00
altogether.
2024-06-21 16:58:57 +02:00
2. Using the [Nouveau driver ](https://wiki.archlinux.org/title/Nouveau ) as
2024-11-06 19:34:37 +01:00
mentioned above.
2024-01-30 22:18:13 +01:00
2024-06-21 16:58:57 +02:00
### Suspend/wakeup issues
2023-09-29 22:36:22 +02:00
2024-02-20 21:16:07 +01:00
Enable the services `nvidia-suspend.service` , `nvidia-hibernate.service` and
`nvidia-resume.service` , they will be started by systemd when needed.
2023-09-29 22:36:22 +02:00
2024-02-20 21:16:07 +01:00
Add `nvidia.NVreg_PreserveVideoMemoryAllocations=1` to your kernel parameters if
2024-04-21 16:35:48 +02:00
you haven't already.
2023-09-29 22:36:22 +02:00
2024-02-20 21:16:07 +01:00
{{< callout > }}
2024-04-20 11:59:06 +02:00
As previously mentioned, suspend functions are currently broken on `nvidia-open-dkms`
2024-02-20 21:16:07 +01:00
[due to a bug ](https://github.com/NVIDIA/open-gpu-kernel-modules/issues/472 ), so
make sure you're on `nvidia-dkms` .
{{< / callout > }}
2023-09-29 22:36:22 +02:00
For Nix users, the equivalent of the above is
2024-02-20 21:16:07 +01:00
2024-11-06 21:55:14 +01:00
```nix {filename="configuration.nix"}
2023-09-29 22:36:22 +02:00
boot.kernelParams = [ "nvidia.NVreg_PreserveVideoMemoryAllocations=1" ];
2024-03-31 13:31:03 +02:00
hardware.nvidia.powerManagement.enable = true;
2023-09-29 22:36:22 +02:00
# Making sure to use the proprietary drivers until the issue above is fixed upstream
2024-03-31 13:31:03 +02:00
hardware.nvidia.open = false;
2023-09-29 22:36:22 +02:00
```
2024-04-20 11:59:06 +02:00
2024-06-21 16:58:57 +02:00
# Still having issues?
2024-04-20 11:59:06 +02:00
If you're still having issues after following this guide, you can join the
2024-06-21 16:58:57 +02:00
[Hyprland Discord ](https://discord.gg/hQ9XvMUjjr ) and ask for help in the
`#hyprland-nvidia` channel.