Turn off your dedicated Nvidia GPU with udev rules

Save battery on your gaming laptop by disabling the Nvidia GPU when you don't need it

Victor Bayas
Victor Bayas
August 23, 2023
2 min read
Turn off your dedicated Nvidia GPU with udev rules
Check out EnvyControl! a much better alternative to this guide

Nvidia GPUs on Linux have always been a headache due to their propietary drivers, but this problem gets worse on Optimus laptops due to inexistent dynamic power management technologies on pre-Turing cards paired with Intel processors older than Coffee Lake. Read the official Nvidia documentation on dynamic PM for Turing and newer cards.

Turning off your Nvidia GPU will result in lower battery consumption when you don’t need it (eg programming, watching videos, etc).

Disable your Nvidia GPU

  1. First blacklist the nouveau and nvidia kernel modules

    • Create a file called /etc/modprobe.d/block-nvidia.conf with the following content:
    /etc/modprobe.d/block-nvidia.conf

    blacklist i2c_nvidia_gpu
    blacklist nouveau
    blacklist nvidia
    blacklist nvidia-drm
    blacklist nvidia-modeset

  2. Add the Udev rules for disabling Nvidia GPU on boot

    • Create a file called /lib/udev/rules.d/50-disable-nvidia.rules with the following content:
    /lib/udev/rules.d/50-disable-nvidia.rules

    # Remove NVIDIA USB xHCI Host Controller devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"
    # Remove NVIDIA USB Type-C UCSI devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{remove}="1"
    # Remove NVIDIA Audio devices, if present
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{remove}="1"
    # Remove NVIDIA VGA/3D controller
    ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{remove}="1"

  3. Now reboot!

Re-enable your Nvidia GPU

  1. Remove the /etc/modprobe.d/block-nvidia.conf file
  2. Remove the /lib/udev/rules.d/50-disable-nvidia.rules file
  3. Reboot

Happy hacking!

Let's build together

I'm always open to new projects and opportunities. Drop me an email or DM me on X and I'll get back to you.

cta

© 2024 Victor Bayas.