mirror of
https://github.com/tmux-plugins/tmux-cpu.git
synced 2026-09-10 07:16:16 -04:00
gram: support cuda-smi
This commit is contained in:
parent
5ad6ef7e10
commit
31b797bb1e
|
|
@ -10,14 +10,13 @@ print_gram_percentage() {
|
|||
gram_percentage_format=$(get_tmux_option "@gram_percentage_format" "$gram_percentage_format")
|
||||
|
||||
if command_exists "nvidia-smi"; then
|
||||
loads=$(nvidia-smi)
|
||||
loads=$(nvidia-smi | sed -nr 's/.*\s([0-9]+)MiB\s*\/\s*([0-9]+)MiB.*/\1 \2/p')
|
||||
elif command_exists "cuda-smi"; then
|
||||
loads=$(cuda-smi)
|
||||
loads=$(cuda-smi | sed -nr 's/.*\s([0-9.]+) of ([0-9.]+) MB.*/\1 \2/p' | awk '{print $2-$1" "$2}')
|
||||
else
|
||||
echo "No GPU"
|
||||
return
|
||||
fi
|
||||
loads=$(echo "$loads" | sed -nr 's/.*\s([0-9]+)MiB\s*\/\s*([0-9]+)MiB.*/\1 \2/p')
|
||||
echo "$loads" | awk -v format="$gram_percentage_format" '{used+=$1; tot+=$2} END {printf format, 100*$1/$2}'
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue