Add Undervolting Support For Nvidia GPUs Via LockedClocks And GpcClkVfOffset
Introduction
Undervolting is a technique used to reduce the voltage supplied to a graphics card, which in turn reduces the power consumption and heat generation. This can be particularly useful for users who want to extend the lifespan of their graphics card or reduce their electricity bills. However, Nvidia's latest driver versions do not allow modifying the voltage of the graphics cards. In this article, we will explore a workaround to achieve effective undervolting on Nvidia GPUs using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions.
Background
Nvidia's driver versions have been limiting the ability to modify the voltage of the graphics cards. However, using the nvidia-ml-py
and pynvml
libraries, it is possible to achieve undervolting with a small workaround. The conceptual idea is to lock the minimum and maximum frequencies using the nvmlDeviceSetGpuLockedClocks
function, which will prevent the GPU from exceeding the voltage corresponding to the maximum frequency. Then, apply an offset using the nvmlDeviceSetGpcClkVfOffset
function.
The Conceptual Idea
The idea is to use the nvmlDeviceSetGpuLockedClocks
function to lock the minimum and maximum frequencies of the GPU. This will prevent the GPU from exceeding the voltage corresponding to the maximum frequency. Then, use the nvmlDeviceSetGpcClkVfOffset
function to apply an offset to the frequency. This offset will make the GPU use a lower voltage to reach the desired frequency.
Example Python Script
Here is an example Python script that demonstrates how to achieve undervolting using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions:
from pynvml import *
nvmlInit()
# This sets the GPU to adjust - if this gives you errors or you have multiple GPUs, set to 1 or try other values.
myGPU = nvmlDeviceGetHandleByIndex(0)
# Set Min and Max core clocks
nvmlDeviceSetGpuLockedClocks(myGPU, 180, 2400)
# Clock offset (0 by default)
nvmlDeviceSetGpcClkVfOffset(myGPU, 200)
In this script, we first initialize the pynvml
library using the nvmlInit
function. Then, we get the handle of the GPU using the nvmlDeviceGetHandleByIndex
function. We set the minimum and maximum core clocks using the nvmlDeviceSetGpuLockedClocks
function, which will prevent the GPU from exceeding the voltage corresponding to the maximum frequency. Finally, we apply an offset to the frequency using the nvmlDeviceSetGpcClkVfOffset
function.
Incorporating into LACT
It would be very elegant to have this functionality directly in the LACT application. LACT is a powerful tool for managing and optimizing the performance of Nvidia graphics cards. Incorporating the undervolting functionality into LACT would make it even more powerful and user-friendly.
Conclusion
Undervolting is a technique used to reduce the voltage supplied to a graphics card, which in turn reduces the power consumption and heat generation. Using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions, it is possible to achieve effective undervolting on Nvidia GPUs. Incorporating this functionality into LACT would make it even more powerful and user-friendly.
Future Work
In the future, we plan to explore other ways to achieve undervolting on Nvidia GPUs. We also plan to incorporate the undervolting functionality into LACT and make it available to users.
References
Code
Here is the code for the example Python script:
from pynvml import *
nvmlInit()
# This sets the GPU to adjust - if this gives you errors or you have multiple GPUs, set to 1 or try other values.
myGPU = nvmlDeviceGetHandleByIndex(0)
# Set Min and Max core clocks
nvmlDeviceSetGpuLockedClocks(myGPU, 180, 2400)
# Clock offset (0 by default)
nvmlDeviceSetGpcClkVfOffset(myGPU, 200)
Note that this code requires the pynvml
library to be installed. You can install it using pip:
pip install pynvml
Introduction
In our previous article, we explored a workaround to achieve effective undervolting on Nvidia GPUs using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions. In this article, we will answer some frequently asked questions about undervolting on Nvidia GPUs.
Q: What is undervolting and why is it useful?
A: Undervolting is a technique used to reduce the voltage supplied to a graphics card, which in turn reduces the power consumption and heat generation. This can be particularly useful for users who want to extend the lifespan of their graphics card or reduce their electricity bills.
Q: How does undervolting work?
A: Undervolting works by locking the minimum and maximum frequencies of the GPU using the nvmlDeviceSetGpuLockedClocks
function. This will prevent the GPU from exceeding the voltage corresponding to the maximum frequency. Then, an offset is applied to the frequency using the nvmlDeviceSetGpcClkVfOffset
function, which makes the GPU use a lower voltage to reach the desired frequency.
Q: What are the benefits of undervolting?
A: The benefits of undervolting include:
- Reduced power consumption
- Reduced heat generation
- Extended lifespan of the graphics card
- Reduced electricity bills
Q: What are the risks of undervolting?
A: The risks of undervolting include:
- Reduced performance
- Increased risk of GPU failure
- Potential for system instability
Q: How do I undervolt my Nvidia GPU?
A: To undervolt your Nvidia GPU, you will need to use the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions. You can use a Python script to achieve this, as shown in our previous article.
Q: What are the system requirements for undervolting?
A: The system requirements for undervolting include:
- Nvidia GPU
- Nvidia driver version 460 or later
- Python 3.6 or later
pynvml
library
Q: Can I undervolt my Nvidia GPU in Windows?
A: Yes, you can undervolt your Nvidia GPU in Windows using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions.
Q: Can I undervolt my Nvidia GPU in Linux?
A: Yes, you can undervolt your Nvidia GPU in Linux using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions.
Q: How do I monitor the performance of my undervolted Nvidia GPU?
A: You can monitor the performance of your undervolted Nvidia GPU using tools such as nvidia-smi
and pynvml
.
Q: Can I use undervolting with other power management techniques?
A: Yes, you can use undervolting with other power management techniques, such as power caps and voltage regulators.
Q: What are the limitations of undervolting?
A: The limitations of undervolting include:
- Reduced performance
- Increased risk of GPU failure
- Potential for system instability
- Limited compatibility with certain games and applications
Conclusion
Undervolting is a powerful technique for reducing the power consumption and heat generation of Nvidia GPUs. By using the nvmlDeviceSetGpuLockedClocks
and nvmlDeviceSetGpcClkVfOffset
functions, you can achieve effective undervolting on your Nvidia GPU. However, it is essential to be aware of the risks and limitations of undervolting and to use it responsibly.
References
Code
Here is the code for the example Python script:
from pynvml import *
nvmlInit()
# This sets the GPU to adjust - if this gives you errors or you have multiple GPUs, set to 1 or try other values.
myGPU = nvmlDeviceGetHandleByIndex(0)
# Set Min and Max core clocks
nvmlDeviceSetGpuLockedClocks(myGPU, 180, 2400)
# Clock offset (0 by default)
nvmlDeviceSetGpcClkVfOffset(myGPU, 200)
Note that this code requires the pynvml
library to be installed. You can install it using pip:
pip install pynvml
Also, make sure to replace the myGPU
variable with the handle of the GPU you want to undervolt.