I have a laptop that has a dedicated NVIDIA GPU. However, this laptop has a problem where the NVIDIA GPU sometimes exits its suspended state and starts using battery, which causes a heavy battery drain.
If the GPU is awake, you can force it to get on the “suspend” state by disabling and enabling the GPU again on Device manager. Once you do this, it gets fixed.
In my attempt to fix this myself, I want to automate the process “detect if the GPU is awake, if so, reset it on the Device Manager”. To detect if the GPU is awake, you can either read its frequency (~300Mhz) or you can check the temperature sensors (its set to 0 celsius when its sleeping).
Therefore, to write some code to fix this, I need to have access to the GPU sensors on Windows.
I’ve tried several ways:
I can’t use DirectX (or similar) APIs to get the temperature, because it will keep the dedicated GPU awake
To keep it simple, I tried to use LibreHardwareMonitor which exposes hardware information as JSON data on a local HTTP server. However, LibreHardwareMonitor itself keeps the dGPU awake and prevents it from going to sleep.
The HWINFO software actually supports the notion of “sleeping GPUs” and it doesn’t wake the NVIDIA GPU when you run it. It also can write sensor info on the Windows Registry so it can be used in other programs (such as Rainmeter). However, the problem is that if you set HWINFO to start on boot, and the NVIDIA GPU isn’t “awake”, then it simply never gets detected, even if it gets awakened.