Skip to content

Instantly share code, notes, and snippets.

@lukeyeager
Last active February 14, 2019 20:09
Show Gist options
  • Save lukeyeager/ec16cfbded7e83bed5649c56234b80db to your computer and use it in GitHub Desktop.
Save lukeyeager/ec16cfbded7e83bed5649c56234b80db to your computer and use it in GitHub Desktop.
Set GPU power levels
#!/bin/bash
set -e
case "$1" in
max) ;;
default) ;;
min) ;;
*)
echo "Usage: $0 [max,default,min]"
exit 1
;;
esac
mode=$1
gpu_count="$(nvidia-smi -L | wc -l)"
for i in $(seq 0 "$(( "$gpu_count" - 1 ))" )
do
case "$mode" in
max)
next="$(nvidia-smi -i "$i" --query-gpu=power.max_limit --format=csv,noheader,nounits)"
;;
default)
next="$(nvidia-smi -i "$i" --query-gpu=power.default_limit --format=csv,noheader,nounits)"
;;
min)
next="$(nvidia-smi -i "$i" --query-gpu=power.min_limit --format=csv,noheader,nounits)"
;;
*)
exit 1
;;
esac
nvidia-smi -i "$i" -pl "$next"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment