Syllo/nvtop

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

qwertychouskie opened this issue · 3 comments

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

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.

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.