#!/bin/bash

if command -v nvidia-smi &> /dev/null; then
    usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | head -n1)
    echo "$usage"
    exit 0
fi

if command -v radeontop &> /dev/null; then
    usage=$(radeontop -d - -l 1 | grep -m1 "gpu" | awk '{print $2}' | tr -d '%')
    echo "$usage"
    exit 0
fi

echo "N/A"
exit 1
