Undervolting NVIDIA GPU under Wayland and X11

I have found great tutorial about NVIDIA GPU undervolting on reddit. According to the author it works under Wayland and X11 but I tested it under Wayland only and it works great. I edited some of the text but it isn’t mine. Author: rexpulli from Reddit: Link

Nvidia doesn’t provide direct access to the voltage value but voltage is still directly tied to the clock: the GPU will auto adjust voltage based on a modifiable curve which binds the two values together (higher clock requires more volts, lower clock requires less volts). If you apply a positive offset to this clock-voltage curve, you force the GPU to use a lower-than-default voltage value for a given clock value, which is effectively an undervolt.

I do this on my 3090 to dramatically lower temperatures for almost no performance loss (I did it on RTX 3060Ti and can confirm that). It’s very easy to do with a Python script which will work in both X11 and Wayland sessions but you need to install a library providing the bindings for the NVIDIA Management Library API.

Install python-nvidia-ml-py (you can use yay instead paru)

paru -S python-nvidia-ml-py

Create Python script

#!/usr/bin/env python
from pynvml import *
nvmlInit()
device = nvmlDeviceGetHandleByIndex(0)
nvmlDeviceSetGpuLockedClocks(device,210,1695)
nvmlDeviceSetGpcClkVfOffset(device,255)
nvmlDeviceSetPowerManagementLimit(device,315000)

Where:

  1. nvmlDeviceSetGpuLockedClocks sets minimum and maximum GPU clocks, I need this because my GPU runs at out-of-specification clock values by default because it’s one of those dumb OC edition cards. You can find valid clock values with:

nvidia-smi -q -d SUPPORTED_CLOCKS

but if you’re happy with the maximum clock values of your GPU, you can omit this line.

  1. nvmlDeviceSetGpcClkVfOffset offsets the curve, this is the actual undervolt. My GPU is stable at +255MHz, you have to find your own value. To clarify again, this doesn’t mean the card will run at a maximum of 1695 + 255 = 1950 MHz, it just means that, for example, at 1695 MHz it will use the voltage that it would’ve used at 1440 MHz before the offset.
  2. nvmlDeviceSetPowerManagementLimit sets the power limit which has nothing to do with undervolting and can be omitted. The GPU will throttle itself (reduce clocks) to stay within this value (in my case 315W).

Save the Python script under name undervolt-nvidia-device. You can test it running it as root in terminal:

sudo python undervolt-nvidia-device

Once you find the correct values, you can run the script with a systemd service on boot. Create file containing:

[Unit]
Description=Undervolt the first available Nvidia GPU device

[Service]
Type=oneshot
ExecStart=/etc/systemd/system/%N

[Install]
WantedBy=graphical.target

Save it under name: undervolt-nvidia-device.service

Put both files in /etc/systemd/system, then reload systemctl:

sudo systemctl daemon-reload

and run service:

sudo systemctl enable --now undervolt-nvidia-device.service

To check how the offsets affect the voltages, you can run in terminal:

watch nvidia-smi -q -d VOLTAGE

while doing some kind of GPU load.

We have a guide in our wiki that seems to use the same program but in a more complicated way with its own python environment. We can probably update it to use the AUR package instead or maybe use this instead. Thanks for the heads up.

Thanks, I didn’t know about guide in the wiki. For me possibility to undervolt GPU is a game changer, because it was something pulling me away from Linux back to Windows.

Guide in wiki is more universal and can be used in distros that can’t use AUR I think.

That’s great but being Arch/CachyOS specific is totally fine if it makes it easier. We are not trying to cater to other distros. We should make our wiki to be as easy to follow as possible for our users. In any case, the guide in the wiki needs some updating anyway.

We will work on nvidia_oc integration as soon there is a systemd service for, e.g GitHub - Dreaming-Codes/nvidia_oc: A simple command line tool to overclock Nvidia GPUs using the NVML library on Linux. This supports both X11 and Wayland.

Did you try this one? Is it still maintained?

Great apps, but some bad news if he finds no newer maintainer;

Edit: If he gets an AMD GPU.

GWE only works on X11.

1 Like

Hey @mafdk

“game changer” Can you elaborate on the advantage you got from undervolting your GPU?

As a 20+ year Linux user, I have recently switched my laptop back to W11 and couldn’t help notice that the NVIDIA drivers seem to perform better when running Forge Webui.

Did you refer to Windows because of the undervolting process or, were you referring to performance differences? I am very curious because I am in the market for a new PC and knowing about this issue can help me to make a better choice. Thanks! :slight_smile:

As far as I know undervolting GPU will only help you get lower temps with the same or almost the same performance. It allows you to get more from the GPU.

I always undervolted my GPU in Windows through Afterburner. As dougg0k wrote, card works with lower temps and is much quieter. Without undervolting in Linux my card has around 70 degrees Celsius and works with 1700, 1800 RPM. After undervolting it is 5 to 10 degrees cooler and fans spin with 1400, 1500 RMP. It makes a big difference for me. Loss of performance is very small.

I heard about “undervolting” and always associated it to something gamers do.

I notice the difference in temperature as well. Running the same application in Linux shows an average temperature of low 60’s.

In W11, system monitor shows that the NVIDIA card reaches high 70’s when I select constant image generation without any breaks in between.

To sum up. Linux GFX card temperatures are lower but so is the the output.
W11 output (more images in the same time frame) is higher because the laptop works “harder” which causes the temperatures to rise.

I will definitely keep Afterburner in mind if it helps to run the system cooler. Thanks! :slight_smile:

It’s probably relative to what you or the OS has done / enabled.



Wayland lacks support everywhere.

Pretty sure this only works under x11