radeontop icon indicating copy to clipboard operation
radeontop copied to clipboard

Option to show only gpu usage percent

Open Lowrida opened this issue 1 year ago • 11 comments

A friend of mine has an older system and a dump to terminal takes a long time. Too long for a nice update in conky. He only wants the gpu usage. Is it possible to make an option for that?

He can't cat the gpu_usage_percent file, because Option not permitted

Lowrida avatar Jun 18 '24 01:06 Lowrida

I'm afraid it won't be any faster if the other values were ignored. The GPU usage queried is an "on/off" value, and to get a percentage it needs to be sampled over a certain time. That is, if you changed it to return immediately after one sample, you'd only get 0% or 100%, not very useful.

I'm not sure what file you're referring to? But for conky, you'd probably want a two-step solution so direct reads are fast. Run radeontop in the background, updating one file, and in conky's config you'd read that file.

clbr avatar Jun 18 '24 06:06 clbr

Thank you for your reply. I revered to /sys/class/drm/card0/device/gpu_busy_percent Where does radeontop get it's gpu usage from? How does it calculate it?

Lowrida avatar Jun 18 '24 07:06 Lowrida

It uses the status register. "At this point in time, which units were on". By default it samples 120 times per second, and outputs once per second. So with the defaults, the calculation is the sum of 120 status reads divided by 120 (and multiplied by 100 so it becomes %).

clbr avatar Jun 18 '24 08:06 clbr

Ah ok, now i get why it takes at least a second to perform a dump. But even when i set tick to 10 it takes the same time to perform a dump..

Lowrida avatar Jun 18 '24 08:06 Lowrida

Tick affects the accuracy, how many times per second to sample. There is no option to change the interval currently. Using too short an interval would cause very jittery (wrong) results.

clbr avatar Jun 18 '24 08:06 clbr

Ok, thanks for the explanation! I guess running it in the background dumping to a file and then cat the file would be quicker then running it every time conky updates.

Lowrida avatar Jun 18 '24 09:06 Lowrida

Problem is, the file grows in size very quickly! Is there an option to not append, but renew the file so only one line is in it?

Lowrida avatar Jun 18 '24 09:06 Lowrida

Not in radeontop, but I'm pretty sure other conky users have made scripts for that. I don't have links at hand, though, sorry.

radeontop -d - | keep-last-line.sh /tmp/gpu

clbr avatar Jun 18 '24 09:06 clbr

radeontop -d - | keep-last-line.sh /tmp/gpu

That pipe doesn't work. That script does not get anything on $@ or $1 .

Lowrida avatar Jun 18 '24 11:06 Lowrida

The file name was for it to output, the input comes through the pipe? If you're not familiar with scripting, you could ask for help at ubuntu forums, etc.

clbr avatar Jun 18 '24 12:06 clbr

Yeah, no problem in scripting here... but the pipe does not work!

Lowrida avatar Jun 18 '24 15:06 Lowrida