NVidia GPU power management with 18.04

I had the same issue with a GTX 1050 on 18.04. I used to have Ubuntu 17.10, and I had 7h of battery when selecting intel GPU. When I upgraded to 18.04, I had 2.5h of battery no matter if I selected Nvidia or Intel, both in the nvidia control panel or through prime-select.

I eventually found this command on some forum: sudo sh -c 'echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control' When entering this command when Intel is selected, my battery life magically goes from 2.5h to 6.5h.

Hope this helps!

Note: I am using the nvidia-390 driver.


I have recently found I was having the very same issue on my laptop with NVIDIA 1050 Ti with either nvidia drivers: 435.21, 440.59. As observed by PowerTop, the NVIDIA PCI bus device was consuming power when selected Intel either via NVIDIA X Server settings or via 'prime-select intel' command. And laptop was pretty hot even if only web browser with static content was open.

The answer above by Sylvain helps to power off the NVIDIA chip, but unfortunately that does not persist after system restart - it has to be done manually every time the laptop starts fresh. I was searching for a solution that would not require using the manual command after each system start, and wish to present it for those who are willing that as well.

Investigation

The issue is known as bug #1765363 and is not fixed in the driver package at the moment of writing this answer.

Present solutions mentioned there (can be found in the discussion under the above bug link) were based on extra tools like Bumblebee (bbswitch), TLP, or even some service-based script jobs. I considered to use them only as a last resort options. Question was: if the solution is simply about the default state of power control mode, how then I can alter it to have a proper value?

Searching for that led me to the NVIDIA driver Power Management page where the System Settings chapter contains the aforementioned command to enable runtime power management for PCI: echo auto > /sys/bus/pci/devices/0000\:01\:00.0/power/control (to be done as root). That works as mentioned above only for current power cycle. Then I have checked and tried the Automated Setup section on that page (create udev rule to enable power management) but it didn't work for Intel graphics mode. After investigating, the reason turned to be pretty obvious: rules are set to enable power management once the NVIDIA driver is loaded and bound to a device. In the 'intel' graphics case the NVIDIA driver is not loaded at all (and so not bound), so the rule is not triggered. But the approach itself was a key: it is about of adding a proper rule.

Solution

It worked by creating a separate udev rules file (inspired by the Automated Setup from NVIDIA driver power management manual). Create a file named like 80-nvidia-poweroff.rules in /lib/udev/rules.d/ directory with the following content:

# Enable runtime PM for NVIDIA VGA/3D controller devices by default (if the driver is not / will not be bound)
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030000", DRIVER=="", TEST=="power/control", ATTR{power/control}="auto"
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x030200", DRIVER=="", TEST=="power/control", ATTR{power/control}="auto"

Save and reboot the system. That's it! No extra tools/scripts needed. PowerTop reports the NVIDIA chip as inactive and its 'Tunables' tab lists 'Runtime PM' state for NVIDIA as 'Good' just after system start. In my case the power consumption shown for Intel mode was ~11-12W, whereas without enabling runtime PM for NVIDIA it was ~22-23W. And the laptop is now barely warm in contrast to being pretty hot before - another proof the runtime PM really does shutdown the chip.

I have also posted this solution on the relevant bug #1765363 page as comment #70.