Skip to content

Instantly share code, notes, and snippets.

@lgalke
Last active October 7, 2022 00:08
Show Gist options
  • Save lgalke/4d551ad72129fadc190074f4745047e4 to your computer and use it in GitHub Desktop.
Save lgalke/4d551ad72129fadc190074f4745047e4 to your computer and use it in GitHub Desktop.
gtop: who uses how much RAM on which GPUs
#!/usr/bin/env bash
GPUID_PID_RAM=`nvidia-smi | sed '0,/Processes:/d' | grep -oe "\<[0-9]\+\(MiB\)\?\>" | xargs`
set -- $GPUID_PID_RAM
while [ -n "$3" ]; do
_u=`ps -q "$2" -eo "uname" | tail -n +2`
printf '%s is using %s on GPU %s\n' "$_u" "$3" "$1"
shift 3
done
@lgalke
Copy link
Author

lgalke commented Oct 7, 2022

  1. Save as gtop in ~/bin.
  2. Ensure ~/bin is present in $PATH.
  3. Run gtop anywhere to quickly find out which GPUs are free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment