Skip to content

Instantly share code, notes, and snippets.

@mkrupczak3
Created February 19, 2024 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkrupczak3/1eed112d8f37c4e6d16eeac1d52ff8a4 to your computer and use it in GitHub Desktop.
Save mkrupczak3/1eed112d8f37c4e6d16eeac1d52ff8a4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Set power limits on all NVIDIA GPUs
# Make sure nvidia-smi exists
command -v nvidia-smi &> /dev/null || { echo >&2 "nvidia-smi not found ... exiting."; exit 1; }
POWER_LIMIT=280
MAX_POWER_LIMIT=$(nvidia-smi -q -d POWER | grep 'Max Power Limit' | tr -s ' ' | cut -d ' ' -f 6)
if [[ ${POWER_LIMIT%.*}+0 -lt ${MAX_POWER_LIMIT%.*}+0 ]]; then
/usr/bin/nvidia-smi --persistence-mode=1
/usr/bin/nvidia-smi --power-limit=${POWER_LIMIT}
else
echo 'FAIL! POWER_LIMIT set above MAX_POWER_LIMIT ... '
exit 1
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment