This script is based one nvidia-smi
, but it can show complete process names and commands.
nvidia-smi |tr -s ' '|grep -Eo "| [0123] [0-9]{3,} .*"|awk -F' ' '{system("s=$(cat /proc/"$2"/cmdline| tr \"\\0\" \" \");u=$(ps -o uname= -p "$2");echo -e "$1"sep$u sep"$5"sep$s" ) }'|sed -e 's/sep/\t/g'
The output is like this
0 5825MiB pythonplayground2.py
0 6319MiB /opt/conda/bin/python-u/cail/model.py
1 137MiB pythonplayground2.py
1 273MiB /usr/bin/python-u/sentsim/cli_predict.py
1 4735MiB /opt/conda/bin/python-u/cail/model.py
1 199MiB /usr/bin/python-u/sentsim/train.py
2 137MiB pythonplayground2.py
2 4735MiB /opt/conda/bin/python-u/cail/model.py
As a compare, the output of nvidia-smi
is
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 3296 C python 5825MiB |
| 0 21266 C /opt/conda/bin/python 6319MiB |
| 1 3296 C python 137MiB |
| 1 8063 C /usr/bin/python 273MiB |
| 1 21266 C /opt/conda/bin/python 4735MiB |
| 1 30439 C /usr/bin/python 199MiB |
| 2 3296 C python 137MiB |
| 2 21266 C /opt/conda/bin/python 4735MiB |
+-----------------------------------------------------------------------------+
That's extremely helpful, thanks