Skip to content

Instantly share code, notes, and snippets.

@abenson
Last active November 23, 2022 00:28
Show Gist options
  • Save abenson/43d2aad730c8520346c90fd028fa40ae to your computer and use it in GitHub Desktop.
Save abenson/43d2aad730c8520346c90fd028fa40ae to your computer and use it in GitHub Desktop.
nvidia-status
#!/bin/sh
if [ "$1" = "-q" ]; then
QUIET="true"
fi
for dev in /proc/driver/nvidia/gpus/*/power; do
busid=$(echo "$dev" | cut -d/ -f6)
if grep -q 'Video Memory:[ ]\+Off' "$dev"; then
if [ -z $QUIET ]; then
echo "Device at $busid is asleep."
fi
exit 0
else
if [ -z $QUIET ]; then
echo "Device at $busid is awake."
nvidia-smi
fi
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment