Gnome/GDM glitches after suspending/sleep

What is the expected outcome:
Typically if you click “suspend” on gnome to sleep your computer, if you turn it back on it will with no visual problems.

What output did you get
Extreme visual glitches on GDM and and DE. Only seems to be fixable with a full restart of the computer.

Meta information
OS: NixOS 24.11.20240906.574d1ea (Vicuna) x86_64
DE: GNOME 46.4
WM: Mutter (Wayland)
Kernel: Linux 6.11.0-cachyos
Nvidia driver version: 560.35.03

My nvidia.nix:

{ config, pkgs, ... }:

{
  hardware = {
    graphics.enable = true;
    nvidia = {
    modesetting.enable = true;
    powerManagement = {
      enable = false; # Disable power management to avoid potential issues
      finegrained = false;
    };
    open = false; # Use proprietary NVIDIA drivers
    nvidiaSettings = true; # Enable NVIDIA settings panel
    package = config.boot.kernelPackages.nvidiaPackages.beta; # Use beta drivers
    };
  };
}

My gdm-display-manager-config.nix:

{
  services.xserver.displayManager.gdm = {
  enable = true;
  wayland = true;
  autoSuspend = false;
  };

  systemd.tmpfiles.rules = [
    # Configuration for GDM monitor setup
    ''f+ /run/gdm/.config/monitors.xml - gdm gdm - <monitors version="2"><configuration><logicalmonitor><x>3840</x><y>0</y><scale>1</scale><monitor><monitorspec><connector>DP-1</connector><vendor>GSM</vendor><product>LG IPS FULLHD</product><serial>0x01010101</serial></monitorspec><mode><width>1920</width><height>1080</height><rate>60.000</rate></mode></monitor></logicalmonitor><logicalmonitor><x>1920</x><y>0</y><scale>1</scale><primary>yes</primary><monitor><monitorspec><connector>DP-2</connector><vendor>AUS</vendor><product>XG248Q</product><serial>KCLMRS019540</serial></monitorspec><mode><width>1920</width><height>1080</height><rate>239.964</rate></mode></monitor></logicalmonitor><logicalmonitor><x>0</x><y>0</y><scale>1</scale><monitor><monitorspec><connector>HDMI-1</connector><vendor>JXC</vendor><product>LED MONITOR</product><serial>0x00000000</serial></monitorspec><mode><width>1920</width><height>1080</height><rate>74.973</rate></mode></monitor></logicalmonitor></configuration></monitors>''
  ];
}

My gnome-desktop-config.nix:

{pkgs, ...}:
{
  services.xserver.desktopManager.gnome = {
  enable = true;
  extraGSettingsOverridePackages = [ pkgs.mutter ];
  extraGSettingsOverrides = ''
    [org.gnome.mutter.wayland]
    xwayland-allow-grabs=true
    xwayland-grab-access-rules=['parsecd']
    [org.gnome.mutter]
    experimental-features=['variable-refresh-rate']
  '';
  };
  
  environment.gnome.excludePackages = [ pkgs.epiphany ]; # Remove unwanted GNOME packages

}

Please let me know if there is any other information I can provide.

According to the Wiki, you might need to enable hardware.nvidia.powerManagement or hardware.nvidia.powerManagement.finegrained to remove the graphical corruption.

1 Like

I see, thank you. Both do not appear to be ideal however. The `hardware.nvidia.powerManagement does not seem to fix issues with suspending the desktop, instead the desktop just does not show a display. For the latter, is there a known decrease in performance using hardware.nvidia.powerManagement.finegrained ? I will opt into just avoiding suspending my desktop completely if it does have an impact on performance (e.g. for gaming).

1 Like

Although I haven’t had corruption issues before, I have both options enabled and I haven’t noticed any decrease in performance. Did the finegrained option fix the corruption issue for you at the cost of performance?

1 Like

I am unable to enable the finegrained feature it seems. First I had an error that I needed to enable PRIME, so I did, but when I tried to build it said I needed to put my PCIE ID to enable it even though I have:

{ config, pkgs, ... }:

{
  hardware = {
    graphics.enable = true;
    nvidia = {
      modesetting.enable = true;
      prime = {
        offload.enable = true;
        nvidiaBusId = "PCI:26:0:0";
      };
      powerManagement = {
        enable = true; # Disable power management to avoid potential issues
        finegrained = true;
        };
      open = false; # Use proprietary NVIDIA drivers  
      nvidiaSettings = true; # Enable NVIDIA settings panel
      package = config.boot.kernelPackages.nvidiaPackages.beta; # Use beta drivers
    };
  };
}

I’m also worried that PRIME might be inappropriate to enable on my machine since it’s a desktop not a laptop.

Ah, reading the Nvidia page on finegrained PM, turns out this feature is only supported for laptops. Could you enable hardware.nvidia.open and try again with and without powerManagement.enable?

1 Like

I have now tested both and they have identical results (visual corruption).

Are you sure that the nvidia-{suspend,hibernate,resume} services are running when enabling powerManagement?

1 Like

I’m not using this option, but I too experienced issues in the past with Nvidia drivers and Gnome. So you might want to try linuxPackages.nvidia_x11_legacy535, that was added due to this issue reported in the ArchLinux forums.

2 Likes

It seems to be running

~ ❱ systemctl status nvidia-{suspend,resume,hibernate}.service
○ nvidia-suspend.service - NVIDIA system suspend actions
     Loaded: loaded (/etc/systemd/system/nvidia-suspend.service; enabled; preset: enabled)
     Active: inactive (dead)

○ nvidia-resume.service - NVIDIA system resume actions
     Loaded: loaded (/etc/systemd/system/nvidia-resume.service; enabled; preset: enabled)
     Active: inactive (dead)

○ nvidia-hibernate.service - NVIDIA system hibernate actions
     Loaded: loaded (/etc/systemd/system/nvidia-hibernate.service; enabled; preset: enabled)
     Active: inactive (dead)
~ 1.1s | 3 ❱ journalctl -u nvidia-suspend.service -n 20
             journalctl -u nvidia-resume.service -n 20
             journalctl -u nvidia-hibernate.service -n 20
Sep 20 22:22:16 sengoku systemd[1]: Starting NVIDIA system suspend actions...
Sep 20 22:22:18 sengoku systemd[1]: nvidia-suspend.service: Deactivated successfully.
Sep 20 22:22:18 sengoku systemd[1]: Finished NVIDIA system suspend actions.
Sep 20 22:22:18 sengoku systemd[1]: nvidia-suspend.service: Consumed 1.403s CPU time, 815.6M memory peak.
-- Boot a8fd3111656f4ebdaba96504879c62aa --
Sep 22 13:00:45 sengoku systemd[1]: Starting NVIDIA system suspend actions...
Sep 22 13:00:48 sengoku systemd[1]: nvidia-suspend.service: Deactivated successfully.
Sep 22 13:00:48 sengoku systemd[1]: Finished NVIDIA system suspend actions.
Sep 22 13:00:48 sengoku systemd[1]: nvidia-suspend.service: Consumed 1.487s CPU time, 667.1M memory peak.
-- Boot 634d4dd4f5ca4013981661028e7b37d8 --
Sep 23 19:50:59 sengoku systemd[1]: Starting NVIDIA system suspend actions...
Sep 23 19:51:01 sengoku systemd[1]: nvidia-suspend.service: Deactivated successfully.
Sep 23 19:51:01 sengoku systemd[1]: Finished NVIDIA system suspend actions.
Sep 23 19:51:01 sengoku systemd[1]: nvidia-suspend.service: Consumed 1.389s CPU time, 785.2M memory peak.
Sep 20 22:24:17 sengoku systemd[1]: Starting NVIDIA system resume actions...
Sep 20 22:24:20 sengoku systemd[1]: nvidia-resume.service: Deactivated successfully.
Sep 20 22:24:20 sengoku systemd[1]: Finished NVIDIA system resume actions.
Sep 20 22:24:20 sengoku systemd[1]: nvidia-resume.service: Consumed 3.280s CPU time, 1.5M memory peak.
-- Boot a8fd3111656f4ebdaba96504879c62aa --
Sep 22 13:02:10 sengoku systemd[1]: Starting NVIDIA system resume actions...
Sep 22 13:02:13 sengoku systemd[1]: nvidia-resume.service: Deactivated successfully.
Sep 22 13:02:13 sengoku systemd[1]: Finished NVIDIA system resume actions.
Sep 22 13:02:13 sengoku systemd[1]: nvidia-resume.service: Consumed 2.371s CPU time, 1.5M memory peak.
-- Boot 634d4dd4f5ca4013981661028e7b37d8 --
Sep 23 19:52:44 sengoku systemd[1]: Starting NVIDIA system resume actions...
Sep 23 19:52:46 sengoku systemd[1]: nvidia-resume.service: Deactivated successfully.
Sep 23 19:52:46 sengoku systemd[1]: Finished NVIDIA system resume actions.
Sep 23 19:52:46 sengoku systemd[1]: nvidia-resume.service: Consumed 2.405s CPU time, 1.5M memory peak.
-- No entries --
~ 1.4s ❱ 

Would this work if I am using Wayland? Just from the name it seems to be for x11 only.

Yes the choice of GPU drivers doesn’t even depend on actually showing graphical stuff - you can even use it with a pure command line setup and access it for computations only.

For now I will avoid suspending my computer since I need latest drivers to play games. Hopefully there is a fix in the near future.

1 Like