Skip to content

Instantly share code, notes, and snippets.

@huide9
Created November 9, 2022 23:46
Show Gist options
  • Save huide9/37fd0c24a737b3aea4c1dfa7f1ceb753 to your computer and use it in GitHub Desktop.
Save huide9/37fd0c24a737b3aea4c1dfa7f1ceb753 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
exist_gpu_process=$(nvidia-smi | grep "No running processes found")
if [[ $exist_gpu_process ]]; then
echo "Nothing to be cleared! No running processes found...";
else
pids=$(nvidia-smi | grep -A 20 'PID' | awk '{print $5}' | tail -n +4)
for pid in $pids
do
kill $pid
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment