bayasdev / envycontrol

Easy GPU switching for Nvidia Optimus laptops under Linux
https://bayas.dev/envycontrol
MIT License
1.14k stars 55 forks source link

[BUG] integrated mode does consume double the power than nvidia mode #166

Open grimba opened 2 months ago

grimba commented 2 months ago

Hey there.

I have a Thinkpad W530. It has a pre Turing GPU, the Quadro K2000M, i use NVIDA Driver Version 470 on Arch Linux. When i use envycontrol to set integrated mode, powertop does not show the NVidia Device in device statistics any more, but with my display backlight set to the darkest mode possible, all pm modes in powertop set to enabled and wifi switched off with the hardware switch, the computer consumes still 18-20W power.

But when i switch to nvidia mode, with the same setting, the power usage is around 10W, half of integrated mode. But the nvidia card is acitve and usable. Even now, while i am writing this text with around 50% backlight and Wifi on, it still uses only 15W of power, still less than integrated mode.

I once had a OpenSuSE Tumbleweed setup, and it brings its own Optimus Switcher, SUSE-PRIME, which uses bbswitch, if it is installed. When i used integrated mode (intel) there, the power usage was around 7W. So i guess SUSE-PRIME was able to turn off the NVIDIA GPU successfully using bbswitch and that value is my reference. On Nvidia Mode, Power Usage was around 12W, so comparable to arch. In fact, that was the only setup, where i was able to successfully turn off the nvidia gpu since the bumblebee times when i bought that laptop.

So i guess there must be something wrong with envycontrol, because it seems as if it does really not turn off the nvidia gpu. Maybe i missed something. I really do not know. Does someone have the same problem?

bayasdev commented 2 months ago

Hi @grimba, EnvyControl relies on udev rules for turning off your GPU so without lspci output I wouldn't be able to tell what's different on your device.

grimba commented 2 months ago

Hey, thanks for the really quick answer. No problem, here the outputs:

integrated: 00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09) 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) 00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04) 00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) 00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4) 00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation QM77 Express Chipset LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller (rev 04) 02:00.0 System peripheral: Ricoh Co Ltd MMC/SD Host Controller (rev 08) 02:00.3 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller (rev 04) 03:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a)

nvidia: 00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09) 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) 00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04) 00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) 00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4) 00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation QM77 Express Chipset LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller (rev 04) 01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K2000M] (rev a1) 01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1) 02:00.0 System peripheral: Ricoh Co Ltd MMC/SD Host Controller (rev 08) 02:00.3 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller (rev 04) 03:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a)

hybrid: 00:00.0 Host bridge: Intel Corporation 3rd Gen Core processor DRAM Controller (rev 09) 00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v2/3rd Gen Core processor PCI Express Root Port (rev 09) 00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09) 00:14.0 USB controller: Intel Corporation 7 Series/C210 Series Chipset Family USB xHCI Host Controller (rev 04) 00:19.0 Ethernet controller: Intel Corporation 82579LM Gigabit Network Connection (Lewisville) (rev 04) 00:1a.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #2 (rev 04) 00:1b.0 Audio device: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller (rev 04) 00:1c.0 PCI bridge: Intel Corporation 7 Series/C216 Chipset Family PCI Express Root Port 1 (rev c4) 00:1c.1 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 2 (rev c4) 00:1c.2 PCI bridge: Intel Corporation 7 Series/C210 Series Chipset Family PCI Express Root Port 3 (rev c4) 00:1d.0 USB controller: Intel Corporation 7 Series/C216 Chipset Family USB Enhanced Host Controller #1 (rev 04) 00:1f.0 ISA bridge: Intel Corporation QM77 Express Chipset LPC Controller (rev 04) 00:1f.2 SATA controller: Intel Corporation 7 Series Chipset Family 6-port SATA Controller [AHCI mode] (rev 04) 00:1f.3 SMBus: Intel Corporation 7 Series/C216 Chipset Family SMBus Controller (rev 04) 01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K2000M] (rev a1) 01:00.1 Audio device: NVIDIA Corporation GK107 HDMI Audio Controller (rev a1) 02:00.0 System peripheral: Ricoh Co Ltd MMC/SD Host Controller (rev 08) 02:00.3 FireWire (IEEE 1394): Ricoh Co Ltd R5C832 PCIe IEEE 1394 Controller (rev 04) 03:00.0 Network controller: Intel Corporation Wi-Fi 6 AX200 (rev 1a)

bayasdev commented 2 months ago

That's strange since the Nvidia GPU is correctly removed from the PCI bus and the kernel shall take care of the power management. In the other hand, bbswitch works by doing a call to the Nvidia GPU telling it to turn off (old method used in the pre Windows 10 era).

grimba commented 2 months ago

I also found out (using your other guide to turn of nvidia gpu), that _SB.PCI0.LPC.EC.PUBS._OFF is the right ACPI call to turn off the GPU. Would it be possible to add a function to turn the GPU off by acpi_call for Devices, where the udev rules do not work? Similar like Suse does with SUSE-PRIME and the optional use of bbswitch?

bayasdev commented 2 months ago

I also found out (using your other guide to turn of nvidia gpu), that _SB.PCI0.LPC.EC.PUBS._OFF is the right ACPI call to turn off the GPU. Would it be possible to add a function to turn the GPU off by acpi_call for Devices, where the udev rules do not work? Similar like Suse does with SUSE-PRIME and the optional use of bbswitch?

The problem with acpi_call is that it's an out of the tree module so it won't work across distros.

grimba commented 2 months ago

I don't think, that this is a problem at all, if it would be an optional feature. Envycontrol would only have to check if acpi_call module is loaded. How the user got the module running, would be out of your scope and no hard dependency of Envycontrol at all. The call itself, in my case _SB.PCI0.LPC.EC.PUBS._OFF, could also be defined by the user and set into the cache json for example. bbswitch is also not a dependency of suse-prime, it is optional.

But i know, both, bbswitch and acpi_call haven't been actively developed since many years. But if Envycontrol could use it, i think it would be the best tool out there atm.

nwildner commented 3 weeks ago

Sup folks. I'm having basically the same problem with envycontrol.

When setting to integrated mode, udev-worker hits hard the CPU, making one of the cores to be pinned on 100% usage, depleting the battery reaaaaaally fast.

It does not reproduce on hybrid mode, but, with that mode it keeps nvidia powered up consuming constant 8W since it is a gaming laptop and having nvidia completely powered down makes battery life when laptop is not docked way better.

Not trying to compare software here or bash anyone, just adding some more data: With optimus-manager I was able to completely shut down Nvidia, but that software also is not being actively maintained lately and had other problems which led me to stop using it.

Edit: yeah, looks like acpi_call is one of the methods being used with that software to turn down nvidia:

    elif switching_mode == "acpi_call":
        _try_load_acpi_call(available_modules)
        _try_set_acpi_call_state("OFF")
alexzapd commented 1 day ago

I had the same problem, basically the gpu is woken up at startup and since the nvidia driver is not loaded (so no power management) it remains in the P0 power state. I was able to solve the problem by: