Last active
November 23, 2022 00:28
-
-
Save abenson/43d2aad730c8520346c90fd028fa40ae to your computer and use it in GitHub Desktop.
nvidia-status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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