Syllo / nvtop

GPU & Accelerator process monitoring for AMD, Apple, Huawei, Intel, NVIDIA and Qualcomm
Other
7.7k stars 282 forks source link

nvtop keeps otherwise-idle dGPU awake, significantly increasing system power consumption #230

Open qwertychouskie opened 11 months ago

qwertychouskie commented 11 months ago

As the title says, if nvtop is running, the Nvidia (or AMD) dGPU is kept powered up even if nothing is using it, which on laptops, can easily double overall idle power consumption.

See also: https://gitlab.com/mission-center-devs/mission-center/-/issues/30

qwertychouskie commented 6 months ago

https://github.com/NVIDIA/open-gpu-kernel-modules/discussions/582

qwertychouskie commented 5 months ago

From https://gitlab.com/mission-center-devs/mission-center/-/issues/30#note_1729912246:

It looks like lsof or fuser might be our best bet to see if applications are actually using the dGPU before calling nvidia-smi or such.

fuser -v /dev/dri/render fuser -v /dev/nvidia lsof /dev/nvidia lsof /dev/dri/render

The one limitation I have found thus far is that fuser only returns processes by the current user, unless ran as root. My concern would be the potential to report "0%" usage when the usage is not actually 0%, due to some other user (or root) process using the dGPU. Invoking pkexec should make sure we are not reporting improperly when root/other users are using the dGPU, but, well, I kinda don't want to always invoke an admin prompt just to avoid an edge case. setuid on a tiny binary dedicated to this purpose is an option, but a potentially risky one.

Syllo commented 4 months ago

I think that I can do something really simple: close all the device handles for the GPUs that are not marked to be monitored. (you can choose which GPU to monitor through the F2 menu). That way the GPU can go back to a deeper state of sleep.