tmux icon indicating copy to clipboard operation
tmux copied to clipboard

Bug: Doesn't detect AMD GPUs

Open shawarden opened this issue 2 years ago • 6 comments

Describe the bug

The status plugin for GPU usage doesn't process AMD and intel GPUs

To Reproduce

Steps to reproduce the behavior:

  1. Have something other than an Nvidia GPU
  2. Add gpu-usage to @dracula-plugins
  3. See 'unknown' in the GPU block

Expected behavior

It should report any GPU usage.

System

  • OS: Arch Linux
  • Tmux Version: 3.3a

Possible fix:

Change gpu_usage.sh line 32 from...

    usage='unknown'

...to something along the lines of...

    usage=$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%\//g' -e 's/\/$//g')

...which can handle one or more GPUs of any type?

Same fixes can be used for gpu_ram_info.sh:

    usage=$(cat /sys/class/drm/card?/device/mem_info_vram_used /sys/class/drm/card?/device/mem_info_vram_total | cat /sys/class/drm/card?/device/mem_info_vram_used /sys/class/drm/card?/device/mem_info_vram_total | numfmt --to=iec-i --suffix=B | sed -z -e 's#\n#/#g' -e 's#/$##g'

...and gpu_power.sh:

    usage=$(echo "$(($(cat /sys/class/drm/card0/device/hwmon/hwmon2/power1_average) / 1000 / 1000))W/$(($(cat /sys/class/drm/card0/device/hwmon/hwmon2/power1_cap_max) / 1000 / 1000))W")

shawarden avatar Jun 15 '23 04:06 shawarden

Looks good. I could never find an API that shows GPU usage, but I guess I wasn't looking hard enough. If you want to implement this, that would be great.

ethancedwards8 avatar Jun 15 '23 16:06 ethancedwards8

Hey @ethancedwards8, is this being worked on ?

pspiagicw avatar Dec 06 '23 03:12 pspiagicw

Sadly no. We (maintainers) don't have AMD hardware and can't really test or develop this feature. If you could implement the feature, providing you have the hardware, that would be amazing.

ethancedwards8 avatar Dec 06 '23 15:12 ethancedwards8

I'm not a contributor, nor do I know how to as I've only ever managed my own git repos, but you can just replace line 32 of scripts/gpu_usage.sh with...

usage="$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%\//g' -e 's/\/$//g')"

...and it will report the gpu usage for any one or more amd or intel gpu(s)

shawarden avatar Dec 09 '23 02:12 shawarden

this works as tested on my mates laptop with an on cpu amd gpu usage="$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%\//g' -e 's/\/$//g')" usage=$(cat /sys/class/drm/card?/device/mem_info_vram_used /sys/class/drm/card?/device/mem_info_vram_total | cat /sys/class/drm/card?/device/mem_info_vram_used /sys/class/drm/card?/device/mem_info_vram_total | numfmt --to=iec-i --suffix=B | sed -z -e 's#\n#/#g' -e 's#/$##g'

Theoreticallyhugo avatar Oct 23 '24 08:10 Theoreticallyhugo

@shawarden would you be ok with this issue being closed, now that your pr is merged, or does it need more work?

Theoreticallyhugo avatar May 26 '25 13:05 Theoreticallyhugo