Fully disabling the Nvidia dGPU on an Optimus Laptop

Hello

I always used NixOS on a single GPU context and this is the first time I will install NixOS on a laptop with an Nvidia Optimus setup: Intel igpu and Nvidia dgpu. The nvidia gpu seems to be pre-turing (Geforce MX 350) which means it does not have support for the official mechanism to automatically shut down when not in use.

I always keep the dedicated gpu on this laptop disabled all the time, as this gives a tremendous power consumption reduction (mostly in idle), and I only use the igpu either way, even for gaming! (Iris Xe is barely worse than the MX 350 it appears). I use bumblebee to do this, but the NixOS wiki says bumblebee is deprecated.

Is there any other way to use bumblebee to fully disable the dgpu? If not, does bumblebee still work and will it stay on the repository for how long?

I also found out about this program, but it seems that as of now it writes on directories that would be read-only on NixOS and immutable systems. Has anybody tried this project?

This module from NixOS hardware does it, just import it: https://github.com/NixOS/nixos-hardware/blob/429f232fe1dc398c5afea19a51aad6931ee0fb89/common/gpu/nvidia/disable.nix

Shouldn’t need to set up offloading at that point I believe, you’ll only have one GPU.

2 Likes

Thank you, I will check this out

It turns out that, after a fresh install, out of the box the Nvidia GPU is already powered off, so I will just keep it like that :frog:

NixOS propagation completed

I’m not sure actually anymore if the dgpu is disabled, so I’ll investigate if it’s actually disabled and then I’ll mark the solution once I’m sure. If it isn’t, I’ll import the hardware module.

Importing the settings in disable.nix alone did not help, but I succeeded in disabling the nvidia dgpu by blacklisting a few more kernel modules: nvidia_drm and nvidia_modeset. I don’t know which fixed it, but one surely did.

I got an amazing power efficiency increase! From an average of 10-16W idle (lowest 10W) to 6-9W (lowest 5W)

For those who want to disable their nvidia dgpu on an optimus laptop, add this to your configuration.nix:

  boot.extraModprobeConfig = ''
    blacklist nouveau
    options nouveau modeset=0
  '';
  
  services.udev.extraRules = ''
    # Remove NVIDIA USB xHCI Host Controller devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA USB Type-C UCSI devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA Audio devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1"
    # Remove NVIDIA VGA/3D controller devices
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1"
  '';
  boot.blacklistedKernelModules = [ "nouveau" "nvidia" "nvidia_drm" "nvidia_modeset" ];
2 Likes

Consider upstreaming that so the next guy benefits too :slight_smile:

1 Like

How would one check power drain of a laptop? I am looking into disabling my dgpu as well, but I am having a hard time figuring out whether it actually gets disabled :rofl:

Powertop would be one tool.

I used tlp with the command tlp-stat -b as root

1 Like