Nvidia GeForce RTX 2080 SUPER hibernate niri broken

After hibernate and resume, the console is completely dead. As in monitors are powered off, but can log in remotely using ssh. Also keyboard is powered off - that is most likely expected because I am using KVM in monitor and monitor is not getting signal.

My display config:

  services.xserver.videoDrivers = [ "nvidia" ];
  services.xserver.enable = false;
  # boot.kernelParams = [ "nvidia.env.preserve_video_memory_allocations=1" ];
  hardware.nvidia = {
    modesetting.enable = true;
    powerManagement.enable = false;
    powerManagement.finegrained = false;
    open = true;
    nvidiaSettings = true;
  };

Through trial and error I found this fixes the problem and allows me console access again:

#!/usr/bin/env sh
pkill niri
sleep 5
modprobe -r nvidia_drm
modprobe -r nvidia_uvm
modprobe -r nvidia
modprobe  nvidia
modprobe  nvidia_uvm
modprobe  nvidia_drm

But of course this means killing my niri session which is a pain. Any ideas? Should I maybe try to nouveau drivers?

This is Nixos 25.05

I also tried open = false; previously but had similar issues.

You’re disabling the service responsible for storing your GPU memory during sleep.

Thanks. For some reason I kept reading that value true :frowning:

Will try.

Yes, that appears to work. At least for 1 out of 1 resume so far…

I disabled the setting several years ago for some reason when experimenting with wayland/nouveau drivers.

The nixos wiki suggests it is experimental, so people get scared. In fairness, the nvidia docs also say so.

However, on any GPU with more than a certain amount of memory sleep simply will not work without it (as those docs explain), so I think that’s stupid and the wiki should just tell you that you need it if you want to be able to use sleep. It doesn’t help that the name isn’t very obvious. It’s also the only option that is off by default that I regularly tell people to enable.

On that note, I’d recommend changing your configuration to just this:

hardware.nvidia.powerManagement.enable = true;

All the other options you set are just the defaults.

If you were using prime offload I’d actually even recommend “finegrained” powermanagement - this has nothing to do with sleep and is actually about your GPU being allowed to turn off when idle. It’s enabled by default on modern cards, but you need the udev rules that setting configures. It also does nothing if you’re not using prime offload, so it’s irrelevant for you, but I’m writing this for people who will try to copy your config.

Besides those two options, unless you have an ancient GPU, you should always just use the default NixOS settings (+ your choice of prime config if you have an iGPU).

1 Like

If I understand Prime Offload is something that is relevant if you have multiple graphics cards in your computer. Which might include one integrated into the motherboard and another add on.

Think this computer has no integrated GPU, so can’t use that.

Yes, I wondered if I actually needed all those values set. Was following the wiki here.

Yep, precisely, you have the nice and simple case. You probably don’t need any of that, and should just configure the single option I’m recommending, and otherwise leave your nvidia configuration at the upstream defaults:

Looks like I do need to explicitly set open to true also:

       Failed assertions:
       - You must configure `hardware.nvidia.open` on NVIDIA driver versions >= 560.
       It is suggested to use the open source kernel modules on Turing or later GPUs (RTX series, GTX 16xx), and the closed source modules otherwise.

Ah, oops, my bad, yes. I had thought it was set to true by default these days, but it looks like I misread the option.

It should default to true, since that is nvidia’s recommendation at this point. Maybe I should commit to a big nvidia module refactor at some point…

1 Like

I have had a bit of minor occasionally weirdness with Firefox. e.g. a Firefox tab froze with a single youtube frame being displayed - I could interact with youtube as evidenced by the audio, but not see what I was doing. Had to close and reopen the tab. But in general it seems to be working pretty good.

Thanks for your help.

That’s unlikely to be caused by your GPU; nvidia don’t support hardware acceleration. If you go through the effort of setting up the third party implementation it could, though.

That only works in Firefox, though, and you have to give up sandboxing and such. Here’s how I set it up: dotfiles/nixos-modules/nvidia/vaapi.nix at bbea499ac61c3f09f7d3b61061fec2166ce2b022 · TLATER/dotfiles · GitHub

That has configuration both for home-manager and NixOS-style firefox config.

Hmm. Something definitely off here, and only seen it on this computer. Basically Firefox Windows can completely freeze (sometimes when starting Firefox from scratch; alternatively just one window freezes and the others are fine), and other times I have seen a Firefox window rapidly alternate between two sets of tabs.

Other Browsers like Brave and Chrome don’t have this problem. But doesn’t smell like a Firefox issue to me; more like a graphics driver issue.

Noticed this even more after turning on power management (might be coincidence not sure).

Is your system properly up-to-date? Nvidia used to cause stuff like that for xwayland windows before explicit sync became supported. Heck, does niri support explicit sync?

That’d also imply you’re using firefox in xwayland mode; I don’t know enough about niri to tell you how to ask it how each window is rendered.

You’re also disabling the xserver. I don’t know if that actually does anything in practice, but it seems to cause removing the nvidia modules from the forcibly loaded kernel modules (and likely many other small unrelated things that ought to stay enabled even without the xserver - it used to just mean “is this system gonna have a desktop” and I don’t think all of NixOS has realized that’s no longer true): nixpkgs/nixos/modules/hardware/video/nvidia.nix at 3acb677ea67d4c6218f33de0db0955f116b7588c · NixOS/nixpkgs · GitHub

Try adding that to your config manually; I’m very suspicious of those lines; technically the modules are supposed to be loaded automatically when needed, but I think that’s known to not actually work. It’s unlikely many people are testing this edge case.

I am using nixos 25.05 from beginning of month.

I currently have niri configured without any X support.

I believe that all the modules are loaded:

$ cat /proc/modules  | grep nvidia
nvidia_uvm 3981312 8 - Live 0x0000000000000000 (O)
nvidia_drm 139264 244 - Live 0x0000000000000000 (O)
nvidia_modeset 2191360 89 nvidia_drm, Live 0x0000000000000000 (O)
nvidia 13324288 2609 nvidia_uvm,nvidia_modeset, Live 0x0000000000000000 (O)

Maybe should try setting services.xserver.enable. I read somewhere that is only for X, not wayland. But I think there still might be some confusion in the nixos config between X and wayland.

Looks like niri doesn’t yet support explicit sync: Explicit sync/drm-syncobj support · Issue #843 · YaLTeR/niri · GitHub

You’ll always have glitches using niri with nvidia until that is fixed.

Thanks for the link.