What do you usually do?
It is assumed that you are using a GPU driver made by NVIDIA.
It seems that it is implemented as part of some framework, but I can't find it, so I'll write down what I'm doing in my case. (If you actually have one, please tell me secretly ...)
First, get the used memory status for each id by entering the following as a shell command.
nvidia-smi --query-gpu=index,memory.used --format=csv,noheader
Extract the result you want to use the following regular expression in the returned result.
^([0-9]+),(\s+)?([0-9]+)(\s+)?MiB$
The above two-step process is described as python code.
Recommended Posts