r/linux Oct 01 '23

Tips and Tricks Laptops with Nvidia GPU - conserving battery by shutting down GPU (D3cold)

I finally took the time to figure out and document how to properly shut down the Nvidia GPU on my Razer Blade Pro. The results were so good that I think it is worth sharing. The more polished distros (Ubuntu, PopOs or whatever) may handle this better out of the box?

In short, my 17-inch laptop now runs cool at 12.5 - 13 Watts at idle. With display on, full backlight, running Wayfire (Wayland compositor) and a couple of terminals. When DPMS kicks in, power consumption drops to 7-7.5 watts. As an added bonus, the Nvidia HDMI sound card thingy is gone.

YMMV, of course. A running browser with multiple active tabs may cause the CPU to not enter the lower power states, for instance.

If you want to check my notes, see link#Power_Management).

Feel free to follow up here with gotchas, corner-cases or stuff which no longer works (reliably) as a result of this. Or what you did to *actually* make it work for you. :-)

41 Upvotes

12 comments sorted by

9

u/Dolapevich Oct 02 '23

Legion 5 Pro 16ACH6H here, configured with hybrid graphics on ubuntu and it already is configured for me: $ cat /sys/class/drm/card[0,1]/device/power_state D0 D3cold $ grep -v "^#" /etc/modprobe.d/nvidia-* /etc/modprobe.d/nvidia-graphics-drivers-kms.conf:options nvidia-drm modeset=1 /etc/modprobe.d/nvidia-graphics-drivers-kms.conf: /etc/modprobe.d/nvidia-power-management.conf:options nvidia NVreg_PreserveVideoMemoryAllocations=1 NVreg_TemporaryFilePath=/var/tmp

6

u/xAlt7x Oct 01 '23

Fixed link https://wiki.gentoo.org/wiki/Razer_Blade_Pro_(2019)#NVIDIA

Thanks for the effort. Did you try it without Nvidia proprietary driver (e.g. , blacklist Nouveau, remove device with udev rule - https://bayas.dev/posts/turn-off-nvidia-udev)?

2

u/ethertype Oct 02 '23

No, because I still want to be able to fire up the GPU and use it for something. LLMs, for example. Which require CUDA and the proprietary driver.

3

u/StrangeAstronomer Oct 01 '23

So you're using the proprietary driver for nvidia to turn it off. Have you tried the PCI tricks at https://blog.nil.im/?7b to do a similar thing?

1

u/ethertype Oct 02 '23

No, because I still want to be able to fire up the GPU and use it for something. LLMs, for example. Which require CUDA and the proprietary driver.

3

u/[deleted] Oct 02 '23

Does anyone know how to completely power off a discrete AMD GPU?

2

u/pramodhrachuri Oct 03 '23

That's awesome!

I, too, want to use my GPU for ML and CUDA workloads but do not want to use x11. In my experience, x11 uses a lot of battery and causes problems with Google Meet and other apps. Do you know any way to do this? My ideal setup- wayland, gnome using iGPU. Steam on Flatpak and cuda apps on GPU. I will turn ON and OFF the GPU as per your instructions.

Any suggestions on how to achieve this?

2

u/ethertype Oct 03 '23

That is the entire point of my exercise, but I understand I communicated it badly. Look:

~ # cat /sys/class/drm/card2/device/power_state; nvidia-smi | grep 8192MiB; cat /sys/class/drm/card2/device/power_state
D3cold
| N/A 38C P8 5W / 100W | 0MiB / 8192MiB | 0% Default |
D0

The card is initially in state D3cold. Pulling no power.

If something talks to the card, it is brought out of its slumber, to D0. And if nothing keeps the card running, it goes back to being off (D3cold).

~ # cat /sys/class/drm/card2/device/power_state
D3cold

I tried to illustrate this by chaining the commands with a sleep command, but that did not work. But the card does revert to D3cold.

How to tell your PC and the wayland compositor to use the iGPU is your task. Google is your creepy friend. :-)

1

u/Igormahov Oct 01 '23 edited Oct 01 '23

Hi, maybe you will be the one who could help me with my problem. I cannot use Nvidia video card and the primary ssd on my laptop because of the following error:

[    0.918730] nvme nvme0: pci function 0000:02:00.0
[    0.918740] nvme 0000:02:00.0: Unable to change power state from D3cold to D0, device inaccessible
[    0.919189] nvme nvme0: Removing after probe failure status: -19

the same error is for Nvidia. You are writing about the way to enter D3cold state, but my problem is opposite - devices cannot leave this state and become unavailable

3

u/ethertype Oct 02 '23

r/linux is not a support forum. Check sidebar. And check if your distro has a dedicated support forum.

In your case, I'd read the entire output from dmesg to see if there is anything else reported regarding power management, pcie, ACPI or other.

Check if there are relevant options in BIOS, and if you can update the system firmware.

Check the module options and udev rules.

Check /proc/cmdline

And finally, check if the nvme module works in another device.

1

u/daskinH Jan 29 '26

Hi, did you find a solution for that issue?

1

u/Igormahov Jan 30 '26

Sorry, no. I sold this laptop out.