Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

gpumode

Lightweight, no-reboot power control for a compute-only NVIDIA Optimus dGPU on Linux laptops. Keep the discrete card asleep at ~0W (D3cold) while you work in the terminal, and let it wake on demand for CUDA / OpenCL / parallel jobs / bruteforce.

It's a thin wrapper around the kernel's PCI runtime power management — no daemon, no optirun, no logout, no unloading modules.

This is not a full GPU mode-switcher. If you need to switch the display between integrated / hybrid / dedicated, use envycontrol, supergfxctl or optimus-manager instead. gpumode targets the case where the display already runs on the iGPU and the NVIDIA card is used purely for compute.

Why

On many Optimus laptops the discrete GPU stays powered even when unused, quietly drawing a few watts (commonly 3–5W). If you live in the terminal on battery, that can be a meaningful chunk of your idle draw. With runtime PM the card drops to D3cold (~0W) whenever it is idle and wakes automatically when compute needs it.

Modes

Command What it does
gpumode off Power-saving: the card sleeps to ~0W (D3cold) when idle and wakes automatically for compute. (auto is an alias.)
gpumode on Keeps the card powered on — no wake latency for a long, heavy session.
gpumode status Shows power state and how long it has been asleep. Does not wake the card.

There is intentionally no "unload the driver" mode: on a Wayland session the compositor typically holds the GPU open (via EGL), so it can't be unloaded — and it doesn't need to be. Runtime PM reaches ~0W with the driver loaded.

Requirements

  • NVIDIA Turing (GTX 16xx / RTX 20xx) or newer — D3cold runtime PM support.
  • Intel Coffee Lake or newer CPU, kernel >= 4.18.
  • The proprietary nvidia driver installed.
  • Display running on the Intel iGPU (the dGPU must not be driving the screen).
  • sudo (setup and switching modes touch udev / sysfs power controls).

Check your card supports the deep power-down:

cat /sys/bus/pci/devices/<dGPU>/d3cold_allowed   # want: 1

Install

git clone https://github.com/anycodef/gpumode.git
cd gpumode
make install          # copies gpumode to ~/.local/bin
gpumode setup         # one time, asks for sudo
sudo reboot           # so the driver picks up fine-grained power management

setup also makes the card power-saving by default at every boot (a udev rule sets power/control=auto), so after the reboot you usually don't need to run anything — it just idles at ~0W.

Verify it works

gpumode status        # does not wake the card

Want to see runtime_status=suspended with a growing "asleep" time while nothing uses the GPU. Then run your CUDA / OpenCL / hashcat job directly — the card wakes on its own — and it goes back to sleep when the job ends.

Tip: don't leave a GPU monitor polling nvidia-smi in a loop — each query wakes the card and keeps it out of D3cold.

How it works

  • setup writes options nvidia NVreg_DynamicPowerManagement=0x02 (/etc/modprobe.d/gpumode.conf) and a udev rule (/etc/udev/rules.d/80-gpumode.rules) that sets power/control=auto on the dGPU and its HD-audio function.
  • off sets power/control=auto, so the kernel runtime-suspends the card to D3cold when idle. on sets power/control=on to pin it powered. status only reads sysfs, so it never wakes the card.

Sway / wlroots note

On a multi-GPU laptop, wlroots opens every GPU at startup (even the unused dGPU), which keeps it powered. Restrict the compositor to the iGPU by pointing WLR_DRM_DEVICES at the Intel card's /dev/dri/cardN. Note that WLR_DRM_DEVICES splits on :, so a /dev/dri/by-path/pci-… value won't work (the PCI address contains colons) — resolve the cardN path instead.

Uninstall

make uninstall
sudo rm -f /etc/modprobe.d/gpumode.conf /etc/udev/rules.d/80-gpumode.rules
sudo udevadm control --reload
sudo reboot

Caveats

  • Hardware support for D3cold varies by laptop/BIOS. If the card never reaches suspended, your firmware may not expose the _PR3 power resource for the PCIe port.

License

MIT — see LICENSE.

About

Lightweight, no-reboot on/off/auto power control for a compute-only NVIDIA Optimus dGPU on Linux (runtime D3cold). Keep the card at ~0W while you work in the terminal, power it up only for CUDA/OpenCL.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages