Skip to content

Instantly share code, notes, and snippets.

@OhadRubin
Created April 23, 2022 05:02
Show Gist options
  • Save OhadRubin/3e9d793223566684b74311fc56a63ca0 to your computer and use it in GitHub Desktop.
Save OhadRubin/3e9d793223566684b74311fc56a63ca0 to your computer and use it in GitHub Desktop.
Kill all the processes on a given GPU
# usage: `killgpu 0` will kill all the processes that are using gpu 0
killgpu (){
# https://forums.developer.nvidia.com/t/11-gb-of-gpu-ram-used-and-no-process-listed-by-nvidia-smi/44459/14
fuser -v /dev/nvidia$@ 2>&1 | grep python | grep -o -E " [0-9]+ " | xargs kill -9
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment