Saturday, July 9, 2022

[FIXED] How to kill process on GPUs with PID in nvidia-smi using keyword?

Issue

How to kill running processes on GPUs for a specific program (e.g. python) in terminal? For example two processes are running with python in the top picture and kill them to see the bottom picture in nvidia-smi

For example two processes are running with python in the top picture and kill them to see the bottom picture in nvidia-smi


Solution

You can grep python in the nvidia-smi and then pass the PID to the kill -9 command, e.g.

sudo kill -9 $( nvidia-smi | grep 'python' | sed -n 's/|\s*[0-9]\s([0-9])\s.*/\1/p' | sed '/^$/d')



Answered By - salehinejad
Answer Checked By - Robin (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.