using the following line I have been able to see processes that use the GPU some of which are mentioned python under the COMMAND column.
sudo fuser -v /dev/nvidia*
which prints:
USER PID ACCESS COMMAND
/dev/nvidia0: root 1197 F...m Xorg
alireza 1451 F...m gnome-shell
alireza 5527 F...m python
alireza 5567 F.... python
alireza 5568 F.... python
how can I kill all the processes which are mentiond python in the COMMAND collumn. But so far i have to do it manually by for each PID by sudo kill -9 <pid> which is not easy if there are many of them.
is there a way to automate this and make it faster? like writing only one command and kill all the PIDs that has pyton in the COMMAND column?