Skip to content

A guide to power management options

Robin Lange edited this page Feb 28, 2021 · 5 revisions

A guide to power management options in optimus-manager

The whole point of the Optimus technology in laptops is that your Nvidia GPU can be turned off when you are not using it, resulting in significant power savings. optimus-manager supports several ways to control the power state of the Nvidia GPU, however since v1.2 they are all disabled by default. The reason for this choice is that pretty much every laptop model model requires a specific method, and using the wrong one can lead to complete system lockups, weird driver issues, or unexpected reboots.

Therefore, don't be surprised if optimus-manager does not improve your battery life straight away : you must first configure it manually to use the proper power switching method, in order for the Nvidia GPU to be turned off when unused. Of course, if your laptop is always plugged in or don't care about battery life, you can just ignore this page and leave the default configuration untouched.

How to configure

The power management options must be set in the configuration file. The user configuration file is located at /etc/optimus-manager/optimus-manager.conf. However it's also possible to submit a TEMPORARY configuration file by running :

optimus-manager --temp-config path/to/file.conf

This temporary configuration will only be loaded once, at the next startup of the optimus-manager service (which normally happens at boot). Then optimus-manager will revert to the normal user configuration. The purpose of this feature is to allow tinkering with the power management options without ending up in a state where the machine just locks up at boot.

If you do end up in such a state though, don't panic : just edit your boot options to mask the optimus-manager service (or boot to console with the multi-user target), then undo your changes. See the FAQ for more details.

Read the following sections for a few suggested configurations. If you are unsure what to do, try them out in that order.

Once you've found a working configuration, write it down in /etc/optimus-manager/optimus-manager.conf so that optimus-manager can use it for every boot.

Configuration 1 : dynamic power management inside the Nvidia driver (Runtime D3 power management)

Note : this configuration is only available for laptops with Turing-generation GPU or above + Coffee Lake Intel CPU or above. If you are not in this case, skip to the next section. It's unclear whether or not AMD CPUs are supported, but you can always try and switch to another method if it doesn't work.

First, make sure your hardware supports configuration is supported. For that, set dynamic_power_management=fine in the [nvidia] section of the configuration file, then reboot to "hybrid" mode and run cat /proc/driver/nvidia/gpus/0000:01:00.0/power (your GPU might have a different PCI address than 0000:01:00.0 but it should be the only folder in gpus/). The line Runtime D3 status: will show whether or not your laptop supports this configuration.

If it's supported, you can either leave dynamic_power_management to fine or set it to coarse (see the configuration file for the difference between those 2 values).

From now on you can keep using your laptop in "hybrid" mode. The "integrated" mode has no interest here because the dynamic power management is already able to power off the card when not in use. However the "nvidia" mode may still be useful if you want to avoid the (small) overhead present when offloading work to the Nvidia GPU or using external displays connected to it.

Configuration 2 : PCI power control

[optimus]
switching=nouveau
pci_power_control=yes
pci_remove=no
pci_reset=no

This configuration loads the open-source driver "nouveau" when in intel mode. To be honest, I am not sure how much control nouveau has on the power management ; however, one nice advantage of loading nouveau is that the video outputs connected to your Nvidia GPU can still work in intel mode, and also dynamic render offloading with DRI_PRIME is supported (though nouveau generally performs too bad for this feature to be really useful).

However nouveau can also be really unstable on some cards, so if you encounter any issue, disable it by setting switching=none and let the Linux kernel handle the power management at the PCI level (that's what pci_power_control=yes does).

If it still does not work, also set pci_remove=yes so that optimus-manager can kick the Nvidia card out of the PCI bus in intel mode, using the kernel's sysfs interface.

Configuration 3 : bbswitch

[optimus]
switching=bbswitch
pci_power_control=no
pci_remove=no
pci_reset=no

This configuration uses the kernel module "bbswitch" to send standard Optimus ACPI calls to the Nvidia GPU in order to turn it off and on.

A few important notes :

  • bumblebee generally uses the same power switching method, so if you already know that bumblebee works for your laptop, you should try this configuration in priority .
  • The bbswitch module has to be installed for your current kernel, from the package bbswitch (or bbswitch-dkms if you're using a non-stock kernel).
  • This method works for a very large range of laptop models, however it's also very prone to causing complete system lockups if a program (like the display server) tries to poke the Nvidia GPU while it's off. This problem can generally be worked around by adding a certain kernel parameter to your boot loader. Different parameters work for different laptop models, so check out this GitHub issue where people have been reporting their findings. Check out this Arch Wiki page to learn how to add a kernel parameter.
  • The value of pci_power_control is ignored if bbswitch is enabled.

Configuration 4 : acpi_call

[optimus]
switching=acpi_call
pci_power_control=no
pci_remove=no
pci_reset=no

This configuration is similar to bbswitch, but uses alternative ACPI calls instead of the standard Optimus ones (it was heavily inspired by the script turn_off_gpu.sh provided by the acpi_call package). There is no way to know in advance which ACPI string works, so the first time you use this method optimus-manager will try a lot of them at once. This will likely cause a spam of AE_NOT_FOUND errors in your kernel log. If a working method is found, it will be saved to a cache and re-used to avoid re-spamming ACPI calls. If for whatever reason you want to clear that cache, delete the file /var/lib/optimus-manager/acpi_call_string.json.

Similarly to bbswitch, you need either the acpi_call or acpi_call-dkms package to be installed. And like bbswitch, pci_power_control is also ignored.

This configuration is a last recourse solution and you should definitely try the bbswitch method first. Even though it has been shown to work fine on a variety of machines, I am not responsible of anything that might happen to yours.

Also, acpi_call is likely to leave the hardware in a bad state, preventing any switching back to Nvidia until the next reboot, or even causing kernel panics. This is where you should use the pci_reset option, as it might mitigate the issue. Try pci_reset=function_level first, then pci_reset=hot_reset. Refer to this StackExchange answer to understand what those options do. Careful : they mess with the hardware directly (particulary hot_reset), so again, use them at your own risk.

Configuration 5 : default power management inside the Nvidia driver

Finally, if none of the above works, revert all the configuration options to their default values and simply use "hybrid" mode instead of "integrated". Unlike "integrated", "hybrid" mode keeps the nvidia driver loaded, which allows it to do some power management of its own like automatically downclocking the card when not in use. It's better than nothing, though not as good for power consumption as completely turning the card off.