Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/amd gpu support #309

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ set -g @dracula-battery-label "Battery"

#### gpu-usage options

Note, currently only the Linux NVIDIA Proprietary drivers are supported. Nouveau and AMD Graphics Cards support are still under development.
Note, currently only the Linux NVIDIA Proprietary drivers are fully supported. Apple, Nouveau and AMD Graphics Cards support are still under development. There is partial support for Apple M chips and AMD Graphics.

Customize label

Expand Down
8 changes: 6 additions & 2 deletions scripts/gpu_ram_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,18 @@ get_gpu()
if [[ "$gpu" == NVIDIA ]]; then
if $gpu_vram_percent; then
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%d%%\n", used / total * 100 ) }')
normalize_percent_len $usage
exit 0
normalize_percent_len $usage
exit 0
else
# to add finer grained info
used_accuracy=$(get_tmux_option "@dracula-gpu-vram-used-accuracy" "d")
total_accuracy=$(get_tmux_option "@dracula-gpu-vram-total-accuracy" "d")
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk "{ used += \$0; total +=\$2 } END { printf(\"%${used_accuracy}GB/%${total_accuracy}GB\n\", used / 1024, total / 1024) }")
fi
elif [[ "$gpu" == Advanced ]]; then
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')
normalize_percent_len $usage
exit 0
else
usage='unknown'
fi
Expand Down
2 changes: 2 additions & 0 deletions scripts/gpu_usage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ get_gpu()
gpu=$(get_platform)
if [[ "$gpu" == NVIDIA ]]; then
usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk '{ sum += $0 } END { printf("%d%%\n", sum / NR) }')
elif [[ "$gpu" == Advanced ]]; then
usage="$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%\//g' -e 's/\/$//g')"
elif [[ "$gpu" == apple ]]; then
usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'active residency' | sed 's/[^0-9.%]//g' | sed 's/[%].*$//g')%"
else
Expand Down