Force GTX1080 performance level to reduce power consumption under Linux

I am using a Pascal GTX 1080 on Gentoo Linux (more specs below).
Being mostly satisfied with the card, I must say I am quite disappointed by the power management.

When idle, the card usually needs 10W or less in the lowest performance level 0.
However, whenever you do something on the laptop, the card very soon jumps to the highest level 4, and drains 40W - 50W of power, significantly reducing battery life and causing fan noise.
In fact, most websites have some kind of animation somewhere forcing the card to level 4, changing to another window in X also makes the card switch to level 4.
TO make thinks even worse, the card switches instantly to level 4, but it takes several seconds to go down to the lower levels step by step until it reaches level 0 again.

What I am missing is an option to limit the card to a certain level while I do not need GPU performance.

I have found several solutions for older cards / drivers setting RegistryDwords for PowerMixerDefaults and PerfLevelSrc in Xorg.conf.
But first, they do not work for me, probably Pascal and the 375.20 driver I am using does not support it.
Second, setting it in the Xorg conf is a bit inconvenient to switch. A command line option for nvidia-smi or nvidia-settings would be way better.

System specs:
Clevo p775dm3-g laptop, intel 6700k CPU, GTX 1080 GPU, no external display
Gentoo Linux 64 bit, Kernel 4.8 NVIDIA 375.20 driver, xorg-server 1.18.4

The only way to force maximum power management is to change X.org settings.

Section "Device"
        Identifier      "Videocard0"
        Driver          "nvidia"
        VendorName      "NVIDIA"
        Option          "Coolbits" "28"
        Option          "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3"
EndSection

This one should work for you.

Does nvidia-smi -pl not work for you? It may not be available on GTX 1080.

I had already tried the

Option "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3"

setting, but the GPU still goes up to 40-50W regularly.

nvidia-smi -pl does not work on my card:

nvidia-smi -pl 30
Changing power management limit is not supported for GPU: 0000:01:00.0.
Treating as warning and moving on.

Actually, can it be used to set the limit that low at all?

It works perfectly for me - you need to reboot to make it work. Also make sure your GPU stays at P0 power level (using nvidia-settings).

I tried a reboot, but doesn’t help. The GPU does not stay at P0 in nvidia-settings.
It jumps up to P4 as soon as I do something that involves any kind of graphics, even opening a web page.
Then, it gradually goes down to P3, P2, P1, P0, which takes seconds.

I have uploaded nvidia-settings screenshot, xorg.conf and xorg.0.log here: https://qon.jwdt.org/nmls/tmp/

Also, there is a field to define a GPU clock offset in nvidia-settings, but it seems to have no effect inserting values there. I even think they are not saved and applied, because when I restart nvidia-settings, it falls back to 0 offset.

Somethings is wrong with NVIDIA drivers on your system. It looks like my proposed configuration is indeed read by your X.org server but it’s not properly applied.

What’s your exact laptop model?

@ahuillet

Indeed it looks like some serious problem with this system and NVIDIA drivers. Might it be caused by the fact that it uses Optimus?

As stated above, the model is clevo p775dm3-g (bought from pc-specialist, they call it octane III).
It does not use optimus.

BTW, can you confirm your system runs Windows without the aforementioned issue?

With a Clevo P651RE6-G, mounting an Nvidia 1060, I had a similar problem.

I had to remove the “PowerMizerLevel” entry. You can find below the setting I am using at the moment in xconf.org (force maximum power savings when on battery, and automatic on AC):

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option         "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x2233; PowerMizerDefault=0x3"
EndSection

Hope it does help you as well.

Without the PowerMizerLevel it doesn’t work either.

I tried it on windows. I can confirm the GPU switches automatically to the lowest power mode P8 as soon as I close all 3d applications (which does not happen on linux).
However, displaying video content in the browser also makes the GPU jump to highest power level, and it is a similar behavior compared to Linux: The GPU goes back to P8 step by step which takes a few seconds - if I leave the browser open. Closing the browser makes it go to P8 immediately.

Perhaps this is related to compositing effects in the KDE window manager. I’ll try a simple window manager next to exclude this.

edit: created separate thread about the issue.

There is no external display connected.

Sounds like a good idea. But then with the provided X.org config no power levels other than P0 must be engaged so I still believe we’re looking at a serious bug.

I tried now with fluxbox, xfce, and gnome desktop. All leading to the same result. GPU reaches lowest power level after some time, but it goes up to highest level immediately when I start some GPU application and then it takes a while to go down again.

I have the same problem with the nvidia 1080 card.
i have ubuntu 16.04 with nvidia 375.20

Section “Device”
Identifier “nvidia”
Driver “nvidia”
BusID “PCI:1@0:0:0”
Option “ConstrainCursor” “off”
Option “RegistryDwords” “PowerMizerEnable=0x1; PerfLevelSrc=0x2222; PowerMizerLevel=0x3; PowerMizerDefault=0x3; PowerMizerDefaultAC=0x3”
Option “NoLogo” “1”
Option “Coolbits” “1”
EndSection

But it looks like it doesnt recognize the settings. Nothing works.

edit: downgrade to 367 everything works fine :)

So that’s a regression indeed.

Does not work for me:

qon@qon ~ $ dmesg | grep nvidia
[...]
[    2.869763] nvidia-modeset: Loading NVIDIA Kernel Mode Setting Driver for UNIX platforms  367.57  Mon Oct  3 20:32:57 PDT 2016
qon@qon ~ $ nvidia-smi 
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 367.57                 Driver Version: 367.57                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    Off  | 0000:01:00.0      On |                  N/A |
| N/A   67C    P0    42W /  N/A |    443MiB /  8104MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

State P0, 42W, with 367.57 driver. Probably we have different issues.

Same problem for me with 980 Ti. I’ve been using this for a long time:

Option "RegistryDwords" "PowerMizerEnable=0x1; PerfLevelSrc=0x3333; PowerMizerDefault=0x2; PowerMizerDefaultAC=0x2"

This keeps the GPU at a max of 405MHz core and 1620MHz memory instead of going to 1582MHz core and 7010MHz memory. It keeps the cooler’s fans off. I don’t need full speed on this GPU on Linux. I only need the full speed when booting to Windows to play games.

At least that’s how it was for a couple years. Now I discovered that this sometimes doesn’t work. I don’t know when the problem started. I only noticed recently, because the fans of the GPU started spinning.

When I looked at the clocks in nvidia-settings, the clocks would go to max and the maximum power level (3) was highlighted. The GPU fan would then also activate after a while. I rebooted, and this stopped happening. The GPU would only go to level 2 (405MHz.) Now today, it stopped working again. I rebooted again, and that fixed it.

It seems that the setting is only respected for a while, and then the driver starts ignoring it, requiring a reboot?

OK, it seems this happens right after loading the driver during boot, not after some amount of uptime. I’m checking to see if it happens on each reboot, and it has just happened now after a kernel upgrade. Kernel on Gentoo was updated from 4.19.61 to 4.19.62. So I installed that, then the nvidia driver kernel modules were recompiled for the new kernel and I rebooted. This caused the bug to appear. I rebooted again and that fixed it.

Perhaps the first boot on a new kernel somehow causes that? I don’t know. I guess I’ll have to keep checking the powermizer page in nvidia-settings after each reboot to see if the bug is consistent.