Unable to wake after suspend on Nvidia

Hello,
I have an HP Victus 15 notebook with Intel Core i3 13420H and Nvidia GeForce RTX 4050. My configuration is utilizing lanzaboote. The problem is, the device won’t wake up after suspend when running nvidia driver.

{ config, lib, pkgs, ... }:

{
  # GENERAL SETTINGS
  hardware.opengl = {
   enable = true;
   driSupport = true;
   extraPackages = with pkgs; [
    vaapiVdpau
    nvidia-vaapi-driver
    intel-media-driver
   ];
  };
  services.xserver.videoDrivers = [ "nvidia" ];

  # GPU SETTINGS 
  hardware.nvidia = {
   modesetting.enable = true;
   open = false;
   powerManagement.enable = true;
   nvidiaSettings = true;
  };
  
  # NVIDIA PRIMUS
  hardware.nvidia.prime = {
   sync.enable = true;
   intelBusId = "PCI:0:2:0";
   nvidiaBusId = "PCI:1:0:0";
  };
}

I have tried powerManagement, powerManagement.finegrained and all the nvidia prime sync options but nothing worked.
Please do suggest a solution.
Thank you

Your config looks mostly fine.

Have you tried updating the nvidia driver to the most recent version (and switching to the open driver as their installer does these days)? Even then, you may be sool on your system, see the known issues on this page of the nvidia docs: Chapter 21. Configuring Power Management Support

You almost definitely want finegrained power management if you’re using prime, by the way, see the explanation of that option in the nvidia docs here: Chapter 22. PCI-Express Runtime D3 (RTD3) Power Management

Though it looks like it’s set by default for recent nvidia GPUs anyway now, and I’m unsure how much of the other NixOS configuration is required to get it to work.

My drivers are the latest because my installation is 3 days old. I tried the open driver and added the kernel parameter ““mem_sleep_default=deep”” but the problem is still there.

Does nvidia-settings show version 560.35.03? NixOS stable’s default nvidia driver is about 6 months old.

Can you share your precise code for that, too?

Nvidia Settings shows driver version 550.78.
as for my boot config, here it is: `
{ config, lib, pkgs, … }:
{

BOOT PARAMETERS

boot.kernelParams = [
“quiet”
“loglevel=3”
“rd.systemd.show_status=false”
“rd.udev.log_level=3”
“udev.log_priority=3”
“resume_offset=533760”
“mem_sleep_default=deep”
];
boot.consoleLogLevel = 0;
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
boot.initrd.systemd.enable = true;
boot.resumeDevice = “/dev/disk/by-uuid/89d54a61-f937-455e-8fc1-af2459981f6e”;
boot.initrd.verbose = false;

BLACKLISTING

boot.blacklistedKernelModules = [ “uvcvideo” “nouveau” ];
}
`
I enable lanzaboote on a separate config file as described in nixos docs.

Deep sleep + nvidia is usually trouble. I don’t think this is strictly a Nix problem. Try removing the deep sleep and see if you can get it to wake up from regular idle.

They enabled this in response to the suggestion to enable that from the nvidia docs.

You can install a more recent driver like so: dotfiles/nixos-config/hosts/yui/nvidia/default.nix at f4ed53e9e78ff41cd2849f389499d3bfd3ffe4c7 · TLATER/dotfiles · GitHub

Note that this won’t update automatically, you’d need to manage it manually. NixOS unstable tends to have an up-to-date nvidia driver, and once 24.11 hits stable will be more up-to-date again.

This won’t per-se fix the problem, sleep and nvidia indeed often don’t play well together. My best suggestion is to read the nvidia docs and see if anything in there applies to your case, and if not, send a bug report to nvidia as described in their documentation.

I tried using 560.35.03 driver from your config and it didn’t work. Is there a way to use intel integrated graphics for Display while simply loading RTX 4050 without using it for display. I plan to use it for compute in the near future.

Ah, I overlooked that. What you’re talking about is called “offload” mode, and enabled with this setting.

It can still be used for display if you use nvidia-offload to start something (or manually set some environment variables), but the GPU will otherwise be off and unused.

This should be the preferred setting for laptops anyway, since it conserves power, but still allows using the nvidia GPU when you need it for something graphically intensive - or for compute.

I tried nvidia-offload before opening this issue, but it didn’t work. I tried it again with the new driver but there is no improvement. As long as I set services.xserver.videoDrivers = [ “nvidia” ] my hardware won’t wake after suspend and if I remove this option the nvidia drivers won’t load into kernel.

Probably not much we can do to help, that’s the issue with proprietary stuff.

As a bit of a last resort, can you share the contents of cat /proc/acpi/wakeup with and without nvidia? Since this only breaks when the nvidia driver is active I doubt it’s involved, but you never know…

here it is

# INTEL
Device	S-state	  Status   Sysfs node
PEG1	  S4	*enabled   pci:0000:00:01.0
PEGP	  S4	*disabled  pci:0000:01:00.0
PEG2	  S4	*disabled
PEGP	  S4	*disabled
PEG0	  S4	*enabled   pci:0000:00:06.0
PEGP	  S4	*disabled  pci:0000:02:00.0
PS2K	  S3	*enabled   pnp:00:02
		*disabled  serio:serio0
RP09	  S4	*disabled
PXSX	  S4	*disabled
RP10	  S4	*disabled
PXSX	  S4	*disabled
RP11	  S4	*disabled
PXSX	  S4	*disabled
RP12	  S4	*disabled
PXSX	  S4	*disabled
RP13	  S4	*disabled
PXSX	  S4	*disabled
RP14	  S4	*disabled
PXSX	  S4	*disabled
RP15	  S4	*disabled
PXSX	  S4	*disabled
RP16	  S4	*disabled
PXSX	  S4	*disabled
RP01	  S4	*disabled
PXSX	  S4	*disabled
RP02	  S4	*disabled
PXSX	  S4	*disabled
RP03	  S4	*disabled
PXSX	  S4	*disabled
RP04	  S4	*disabled
PXSX	  S4	*disabled
RP05	  S4	*enabled   pci:0000:00:1c.0
PXSX	  S4	*disabled  pci:0000:03:00.0
		*disabled  platform:rtsx_pci_sdmmc.0
RP06	  S4	*disabled
PXSX	  S4	*disabled
RP07	  S4	*disabled
PXSX	  S4	*disabled
RP08	  S4	*enabled   pci:0000:00:1c.7
PXSX	  S4	*enabled   pci:0000:04:00.0
RP17	  S4	*disabled
PXSX	  S4	*disabled
RP18	  S4	*disabled
PXSX	  S4	*disabled
RP19	  S4	*disabled
PXSX	  S4	*disabled
RP20	  S4	*disabled
PXSX	  S4	*disabled
RP21	  S4	*disabled
PXSX	  S4	*disabled
RP22	  S4	*disabled
PXSX	  S4	*disabled
RP23	  S4	*disabled
PXSX	  S4	*disabled
RP24	  S4	*disabled
PXSX	  S4	*disabled
XHCI	  S4	*enabled   pci:0000:00:14.0
XDCI	  S4	*disabled
HDAS	  S4	*disabled  pci:0000:00:1f.3
CNVW	  S4	*disabled  pci:0000:00:14.3
TXHC	  S4	*enabled   pci:0000:00:0d.0
TDM0	  S4	*disabled
TDM1	  S4	*disabled
TRP0	  S4	*disabled
PXSX	  S4	*disabled
TRP1	  S4	*disabled
PXSX	  S4	*disabled
TRP2	  S4	*disabled
PXSX	  S4	*disabled
TRP3	  S4	*disabled
PXSX	  S4	*disabled
AWAC	  S4	*enabled   platform:ACPI000E:00
PWRB	  S4	*enabled   platform:PNP0C0C:00

# NVIDIA
Device	S-state	  Status   Sysfs node
PEG1	  S4	*enabled   pci:0000:00:01.0
PEGP	  S4	*disabled  pci:0000:01:00.0
PEG2	  S4	*disabled
PEGP	  S4	*disabled
PEG0	  S4	*enabled   pci:0000:00:06.0
PEGP	  S4	*disabled  pci:0000:02:00.0
PS2K	  S3	*enabled   pnp:00:02
		*disabled  serio:serio0
RP09	  S4	*disabled
PXSX	  S4	*disabled
RP10	  S4	*disabled
PXSX	  S4	*disabled
RP11	  S4	*disabled
PXSX	  S4	*disabled
RP12	  S4	*disabled
PXSX	  S4	*disabled
RP13	  S4	*disabled
PXSX	  S4	*disabled
RP14	  S4	*disabled
PXSX	  S4	*disabled
RP15	  S4	*disabled
PXSX	  S4	*disabled
RP16	  S4	*disabled
PXSX	  S4	*disabled
RP01	  S4	*disabled
PXSX	  S4	*disabled
RP02	  S4	*disabled
PXSX	  S4	*disabled
RP03	  S4	*disabled
PXSX	  S4	*disabled
RP04	  S4	*disabled
PXSX	  S4	*disabled
RP05	  S4	*enabled   pci:0000:00:1c.0
PXSX	  S4	*disabled  pci:0000:03:00.0
		*disabled  platform:rtsx_pci_sdmmc.0
RP06	  S4	*disabled
PXSX	  S4	*disabled
RP07	  S4	*disabled
PXSX	  S4	*disabled
RP08	  S4	*enabled   pci:0000:00:1c.7
PXSX	  S4	*enabled   pci:0000:04:00.0
RP17	  S4	*disabled
PXSX	  S4	*disabled
RP18	  S4	*disabled
PXSX	  S4	*disabled
RP19	  S4	*disabled
PXSX	  S4	*disabled
RP20	  S4	*disabled
PXSX	  S4	*disabled
RP21	  S4	*disabled
PXSX	  S4	*disabled
RP22	  S4	*disabled
PXSX	  S4	*disabled
RP23	  S4	*disabled
PXSX	  S4	*disabled
RP24	  S4	*disabled
PXSX	  S4	*disabled
XHCI	  S4	*enabled   pci:0000:00:14.0
XDCI	  S4	*disabled
HDAS	  S4	*disabled  pci:0000:00:1f.3
CNVW	  S4	*disabled  pci:0000:00:14.3
TXHC	  S4	*enabled   pci:0000:00:0d.0
TDM0	  S4	*disabled
TDM1	  S4	*disabled
TRP0	  S4	*disabled
PXSX	  S4	*disabled
TRP1	  S4	*disabled
PXSX	  S4	*disabled
TRP2	  S4	*disabled
PXSX	  S4	*disabled
TRP3	  S4	*disabled
PXSX	  S4	*disabled
AWAC	  S4	*enabled   platform:ACPI000E:00
PWRB	  S4	*enabled   platform:PNP0C0C:00

my current nvidia config ( after recording /proc/acpi/wakeup for intel and nvidia separately, I have re-enabled both the drivers )

{ config, lib, pkgs, ... }:

{
  # GENERAL SETTINGS
  hardware.opengl = {
   enable = true;
   driSupport = true;
  };

  services.xserver.videoDrivers = [ "nvidia" "intel" ];

  # GPU SETTINGS 
  hardware.nvidia = {
   modesetting.enable = true;
   open = true;
   powerManagement.finegrained = true;
   nvidiaSettings = false;
   package = config.boot.kernelPackages.nvidiaPackages.mkDriver {
      version = "560.35.03";
      sha256_64bit = "sha256-8pMskvrdQ8WyNBvkU/xPc/CtcYXCa7ekP73oGuKfH+M=";
      sha256_aarch64 = "sha256-s8ZAVKvRNXpjxRYqM3E5oss5FdqW+tv1qQC2pDjfG+s=";
      openSha256 = "sha256-/32Zf0dKrofTmPZ3Ratw4vDM7B+OgpC4p7s+RHUjCrg=";
      settingsSha256 = "sha256-kQsvDgnxis9ANFmwIwB7HX5MkIAcpEEAHc8IBOLdXvk=";
      persistencedSha256 = "sha256-E2J2wYYyRu7Kc3MMZz/8ZIemcZg68rkzvqEwFAL3fFs=";
    };
   dynamicBoost.enable = true;
  };
  
  # NVIDIA PRIMUS
  hardware.nvidia.prime = {
  offload = {
   enable = true;
   enableOffloadCmd = true;
  };
  intelBusId = "PCI:0:2:0";
  nvidiaBusId = "PCI:1:0:0";`Preformatted text`
  };
}

My kernel parameters

 boot.kernelParams = [
   "loglevel=2"
   "rd.systemd.show_status=false"
   "rd.udev.log_level=0"
   "udev.log_priority=2"
   "resume_offset=533760"
   "mem_sleep_default=deep"
  ];