Nvidia GPU doesn't shut down

My /etc/nixos/nvidia.nix (imported)

{...}: {
  # completely disable drivers if commented
  services.xserver.videoDrivers = [ "amdgpu" "nvidia" ];

  hardware.nvidia = {
    # caused issues 
    # open = true;

    powerManagement.enable = true;
    powerManagement.finegrained = true;

    prime = {
      offload = {
        enable = true;
        enableOffloadCmd = true;
      };

      nvidiaBusId = "PCI:1:0:0";
      amdgpuBusId = "PCI:5:0:0";
    };

    nvidiaSettings = false;
  };
}

nvidia-smi

Thu Feb 22 12:19:39 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 545.29.02              Driver Version: 545.29.02    CUDA Version: 12.3     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA GeForce RTX 3050 ...    Off | 00000000:01:00.0 Off |                  N/A |
| N/A   45C    P3             749W /  30W |      2MiB /  4096MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|  No running processes found                                                           |
+---------------------------------------------------------------------------------------+

I have a 3050 (laptop version) on a asus rog strix g15 laptop. The powerManagement.finegrained option should turn off my gpu if there’s no processes running on my gpu. nvtop shows, that there is some memory allocated on my gpu despite having no running processes.

All of my applications also start slower if I have my nvidia driver enabled at all. (e.g. kitty - maybe because it’s gpu accelerated? But the nvidia driver shouldn’t really interfere because it’s ran on the iGPU)

here’s my dmesg. Not sure whether the ACPI errors are related

[    3.149594] nvidia: loading out-of-tree module taints kernel.
[    3.149600] nvidia: module license 'NVIDIA' taints kernel.
[    3.149601] Disabling lock debugging due to kernel taint
[    3.229271] nvidia-nvlink: Nvlink Core is being initialized, major device number 243

[    3.229741] nvidia 0000:01:00.0: enabling device (0000 -> 0003)
[    3.230455] nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[    3.273529] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  545.29.02  Thu Oct 26 21:21:38 UTC 2023
[    3.279832] systemd-journald[682]: Received client request to flush runtime journal.
[    3.302728] nvidia_uvm: module uses symbols nvUvmInterfaceDisableAccessCntr from proprietary module nvidia, inheriting taint.
[    3.321736] nvidia-uvm: Loaded the UVM driver, major device number 241.
[    3.324181] systemd-journald[682]: /var/log/journal/8b734473cd2840769f290db0cd1b9321/system.journal: Journal file uses a different sequence number ID, rotating.
[    3.324184] systemd-journald[682]: Rotating system journal.
[    3.330376] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  545.29.02  Thu Oct 26 20:52:21 UTC 2023
[    3.338980] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[    3.353298] ACPI Warning: \_SB.NPCF._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20220331/nsarguments-61)
[    3.353333] ACPI Warning: \_SB.PCI0.GPP0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20220331/nsarguments-61)
[    3.449145] hid: raw HID events driver (C) Jiri Kosina
[    3.456303] ACPI: AC: AC Adapter [ADP0] (off-line)
[    3.457149] input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:35/PNP0C0D:00/input/input2
[    3.457576] ACPI: battery: Slot [BAT0] (battery present)
[    3.458220] ACPI: button: Lid Switch [LID0]
[    3.463835] input: Power Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input3
[    3.465144] ACPI: button: Power Button [PWRB]
[    3.466001] input: Sleep Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0E:00/input/input4
[    3.466967] thermal LNXTHERM:00: registered as thermal_zone0
[    3.466969] ACPI: thermal: Thermal Zone [TZ01] (58 C)
[    3.468906] ACPI: button: Sleep Button [SLPB]
[    3.149594] nvidia: loading out-of-tree module taints kernel.
[    3.149600] nvidia: module license 'NVIDIA' taints kernel.
[    3.149601] Disabling lock debugging due to kernel taint
[    3.229271] nvidia-nvlink: Nvlink Core is being initialized, major device number 243

[    3.229741] nvidia 0000:01:00.0: enabling device (0000 -> 0003)
[    3.230455] nvidia 0000:01:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none
[    3.273529] NVRM: loading NVIDIA UNIX x86_64 Kernel Module  545.29.02  Thu Oct 26 21:21:38 UTC 2023
[    3.279832] systemd-journald[682]: Received client request to flush runtime journal.
[    3.302728] nvidia_uvm: module uses symbols nvUvmInterfaceDisableAccessCntr from proprietary module nvidia, inheriting taint.
[    3.321736] nvidia-uvm: Loaded the UVM driver, major device number 241.
[    3.324181] systemd-journald[682]: /var/log/journal/8b734473cd2840769f290db0cd1b9321/system.journal: Journal file uses a different sequence number ID, rotating.
[    3.324184] systemd-journald[682]: Rotating system journal.
[    3.330376] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  545.29.02  Thu Oct 26 20:52:21 UTC 2023
[    3.338980] [drm] [nvidia-drm] [GPU ID 0x00000100] Loading driver
[    3.353298] ACPI Warning: \_SB.NPCF._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20220331/nsarguments-61)
[    3.353333] ACPI Warning: \_SB.PCI0.GPP0.PEGP._DSM: Argument #4 type mismatch - Found [Buffer], ACPI requires [Package] (20220331/nsarguments-61)
[    3.449145] hid: raw HID events driver (C) Jiri Kosina
[    3.456303] ACPI: AC: AC Adapter [ADP0] (off-line)
[    3.457149] input: Lid Switch as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:35/PNP0C0D:00/input/input2
[    3.457576] ACPI: battery: Slot [BAT0] (battery present)
[    3.458220] ACPI: button: Lid Switch [LID0]
[    3.463835] input: Power Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0C:00/input/input3
[    3.465144] ACPI: button: Power Button [PWRB]
[    3.466001] input: Sleep Button as /devices/LNXSYSTM:00/LNXSYBUS:00/PNP0C0E:00/input/input4
[    3.466967] thermal LNXTHERM:00: registered as thermal_zone0
[    3.466969] ACPI: thermal: Thermal Zone [TZ01] (58 C)
[    3.468906] ACPI: button: Sleep Button [SLPB]

Didn’t find anything related in journalctl

To shut down GPU for good:

To stops apps from lagging on startup:

disable NVIDIA in your hardware.nix, don’t add NVIDIA driver

If you want to use NVIDIA, but get rid of startup lag, look into hardware.nvidia.nvidiaPersistenced

This is episode III of Plasma Emojier Too Slow, Episode IV :rofl: