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
[Nouveau driver ](https://wiki.archlinux.org/title/Nouveau ). Under the
proprietary Nvidia drivers category, there are 3 of them: the current driver
named 'nvidia' (or 'nvidia-dkms' to use with custom linux kernels) which is
under active development, the legacy 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-20 11:59:06 +02:00
If your card is supported by the proprietary nvidia drivers, there is a very
high chance that you will most likely want to use those. Benefits include but
are not limited to:
2024-02-20 21:16:07 +01:00
2024-04-20 11:59:06 +02:00
- (Much) better gaming performance
- Better power management on recent 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
most likely be the case for
[older cards ](https://wiki.archlinux.org/title/NVIDIA#Unsupported_drivers )
## How to get Hyprland to possibly run on Nvidia (Proprietary)
Install the correct headers package for your current kernel. For the example of
the `linux-zen` kernel on Arch Linux, this package would be `linux-zen-headers` .
Install the required nvidia packages. For most cases, this would be `nvidia-dkms`
(or `nvidia-open-dkms` for the open source ones),
and `nvidia-utils` . If you'd like to game via Wine or even natively, it would be
in your best interest to also install `lib32-nvidia-utils` .
{{< callout > }}
Even if your GPU is listed as supported by the `nvidia-open-dkms` driver, at this
point in time, it is still not up to feature parity with the proprietary drivers.
One issue with the open drivers is that it could cause problems with suspend in
general, let that be closing the lid on your laptop or by manually triggering one.
Overall, you'd be better off with `nvidia-dkms` right now, but Hyprland should work
similarly between the two.
{{< / callout > }}
Next up, you need to enable modeset for nvidia, this can be done via editing
the kernel paramaters for your bootloader.
2022-08-12 20:46:36 +02:00
2024-02-20 21:16:07 +01:00
For people using [systemd-boot ](https://wiki.archlinux.org/title/systemd-boot )
2024-04-20 11:59:06 +02:00
you can do this by adding `nvidia_drm.modeset=1` to the end of
`/boot/loader/entries/arch.conf` .
For people using
[GRUB ](https://wiki.archlinux.org/title/GRUB ) you can do this by adding
2024-02-20 21:16:07 +01:00
`nvidia_drm.modeset=1` to the end of `GRUB_CMDLINE_LINUX_DEFAULT=` in
2024-04-20 11:59:06 +02:00
`/etc/default/grub` , then running `sudo grub-mkconfig -o /boot/grub/grub.cfg` .
For others check out
2024-02-20 21:16:07 +01:00
[kernel parameters ](https://wiki.archlinux.org/title/Kernel_parameters ) and how
to add `nvidia_drm.modeset=1` to your specific bootloader.
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
{{< callout > }}
There has been a lot of debate on which of `nvidia_drm` or `nvidia-drm`
is correct for this kernel parameter. It has been confirmed that either
of these will work.
{{< / callout > }}
2024-02-20 21:16:07 +01:00
in `/etc/mkinitcpio.conf` add `nvidia nvidia_modeset nvidia_uvm nvidia_drm` to
your `MODULES`
2022-08-27 23:56:52 +02:00
2024-04-20 11:59:06 +02:00
For example, a clean `MODULES` line would now look like this:
```sh
MODULES=(nvidia nvidia_modeset nvidia_uvm nvidia_drm)
```
2022-08-27 23:56:52 +02:00
2024-04-20 11:59:06 +02:00
Now, run `sudo mkinitcpio -P` . This will regenerate the initcpios for all kernels
currently installed on the system. If you see any errors here about missing
nvidia modules, it is highly probable that you forgot to install the correct
headers package. Make sure you install the headers package for your kernel and
run this command again.
2022-08-27 23:56:52 +02:00
2023-04-22 22:26:23 +02:00
More information is available here:
[https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting ](https://wiki.archlinux.org/title/NVIDIA#DRM_kernel_mode_setting )
2024-04-20 11:59:06 +02:00
Export these variables in your hyprland config:
2024-02-20 21:16:07 +01:00
2024-04-20 11:59:06 +02:00
```sh
env = LIBVA_DRIVER_NAME,nvidia
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1
```
2023-02-07 13:25:30 +01:00
2024-04-20 11:59:06 +02:00
Lastly, you also need to install a few packages to get some apps
to function natively with Wayland. Have a look at [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
We can achieve VA-API acceleration on Nvidia and Wayland with the help of the
[nvidia-vaapi-driver ](https://github.com/elFarto/nvidia-vaapi-driver ). This may
solve certain issues in Electron apps, and it will also allow for GPU decoding
for videos on the web, with benefits including higher performance video playback
and also higher power efficiency during video playback.
Its install instructions are available in the README, however, a quick guide will
be given here:
- Install the package. On Arch, this is `libva-nvidia-driver` in the official
repos.
2024-02-20 21:16:07 +01:00
2024-04-20 11:59:06 +02:00
- export this variable in your hyprland config:
```sh
env = NVD_BACKEND,direct
```
see [here ](https://github.com/elFarto/nvidia-vaapi-driver?tab=readme-ov-file#upstream-regressions )
for more information on this environment variable.
- Enable the services `nvidia-suspend.service` , `nvidia-hibernate.service` and
`nvidia-resume.service`
- Add `nvidia.NVreg_PreserveVideoMemoryAllocations=1` to your kernel parameters if
you don't have it already. This will solve issues with corrupted desktop / videos
after waking.
- You can check the README to get it working for Firefox.
## Other issues to look out for
### Regarding environment variables
- If you encounter crashes in Firefox, remove the line
`env = GBM_BACKEND,nvidia-drm` .
- If you face problems with Discord windows not displaying or screen sharing not
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` .
### How to possibly get multi-monitor working with hybrid graphics
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-04-20 11:59:06 +02:00
### Fixing 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.
To fix the flickering, try running the apps with native Wayland instead.
For most Electron apps, you should be fine just adding this
environment variable to your config:
2022-08-12 20:46:36 +02:00
```sh
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-04-20 11:59:06 +02:00
This has been confirmed to work on Vesktop, VSCodium and Obsidian and will probably
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`
package in the AUR. Then, enable the Wayland backend in
`/etc/spotify-launcher.conf` by uncommenting this line:
```sh
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-04-20 11:59:06 +02:00
With NixOS, you can also try setting the `NIXOS_OZONE_WL` environment variable
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
wayland, the root cause of the flickering will likely be solved
in the 555 series of nvidia driver updates.
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
### Fixing flickering in XWayland games specifically
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
The symptoms of this widespread issue include XWayland games flickering in
a way which makes them unplayable. Repeated frames, random presenting of
black frames, and overall weirdness. This is a result of a multitude of
issues which will be solved soon via Nvidia driver updates, but for now
you have a few possible fixes:
- Install xorg-xwayland-git (AUR). This git package includes this [PR ](https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/967 )
which implements the "Explicit Sync" protocol.
This will fix it in some, if not all cases. However if it doesn't,
try the next solution. Once the 555 series of drivers are released, this
should completely fix the issue.
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
- Install older nvidia drivers which do not exhibit this problem. The
last ones which would work will be the 535xx series of drivers. These
can be installed easily on Arch via [these AUR packages ](https://aur.archlinux.org/packages?O=0&K=535xx )
2022-08-12 20:46:36 +02:00
2024-04-20 11:59:06 +02:00
More info about explicit sync is available
[on this blog ](https://planet.kde.org/xavers-blog-2024-04-05-explicit-sync/ ).
2022-08-13 01:47:48 +02:00
2024-04-20 11:59:06 +02:00
### Fixing other random flickering (nuclear method)
Do note that this forces performance mode to be active, resulting in
increased power-consumption (from 22W idle on an RTX 3070TI, to 74W).
This is probably not needed for most users, so only apply these 'fixes' if
you in-fact 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
2022-08-13 19:06:18 +02:00
```sh
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
- lowering your monitors' refresh rate, as this can stop the flickering
altogether
- using the [Nouveau driver ](https://wiki.archlinux.org/title/Nouveau ) as
mentioned above
2024-01-30 22:18:13 +01:00
2024-04-20 11:59:06 +02:00
### Fixing 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
you don't have it 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
2023-09-29 22:36:22 +02:00
```nix
# configuration.nix
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
## Still having issues?
If you're still having issues after following this guide, you can join the
[Hyprland Discord ](https://discord.gg/hypr ) and ask for help in the
`#hyprland-nvidia` channel. Hopefully someone will be able to help you out.