aristocratos / btop

A monitor of resources
Apache License 2.0
21.25k stars 650 forks source link

[REQUEST] Per process GPU usage #968

Open w8jcik opened 1 week ago

w8jcik commented 1 week ago

btop shows total GPU usage and per GPU usage very well, but it doesn't show per process GPU usage.

I believe that there is an interface that offers all necessary information, independent from GPU vendor.

Resource monitor called Resources https://github.com/nokyan/resources doesn't seem to have much code specific to any GPU vendor, yet it is able to retrieve GPU usage and even per process GPU usage.

image

The information is available through fdinfo interface.

cat /proc/2960/fdinfo/12

pos:    0
flags:  02104002
mnt_id: 1717
ino:    889
drm-driver: i915
drm-client-id:  28
drm-pdev:   0000:00:02.0
drm-total-system0:  472424 KiB
drm-shared-system0: 85472 KiB
drm-active-system0: 0
drm-resident-system0:   466168 KiB
drm-purgeable-system0:  17660 KiB
drm-total-stolen-system0:   0
drm-shared-stolen-system0:  0
drm-active-stolen-system0:  0
drm-resident-stolen-system0:    0
drm-purgeable-stolen-system0:   0
drm-engine-render:  443069963784 ns
drm-engine-copy:    0 ns
drm-engine-video:   0 ns
drm-engine-capacity-video:  2
drm-engine-video-enhance:   0 ns

where 2960 is a PID. I am not sure where the 12 comes from. Maybe all files need to be opened.

Interpretation of drm-engine-render needs extra steps:

It would be great to have an additional column in processes table of btop that would show GPU usage of each process.