Skip to content

Instantly share code, notes, and snippets.

@zxybazh
Created April 17, 2020 05:15
Show Gist options
  • Save zxybazh/dc36ff73046ad09d903fc2435f0e603f to your computer and use it in GitHub Desktop.
Save zxybazh/dc36ff73046ad09d903fc2435f0e603f to your computer and use it in GitHub Desktop.
Script to record maxmimum GPU memory usage of the first card using nvidia-smi in a time period.
#!/bin/bash
max=0
while true; do
tmp=$(nvidia-smi | grep 11019MiB | awk '{split($0,a,"|"); print a[3]}' | awk '{split($0, a, "/"); print a[1]}' | awk 'NR==1{print $1}' | awk '{split($0, a, "M"); print a[1]}')
if [[ "$tmp" > "$max" ]]; then
max=$tmp
fi
echo $max "MiB"
sleep .5;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment