gpuopenanalytics / pynvml

Provide Python access to the NVML library for GPU diagnostics
BSD 3-Clause "New" or "Revised" License
220 stars 31 forks source link

How to get the process pid in docker? #36

Open xianjiez opened 3 years ago

xianjiez commented 3 years ago

I get the process pid in docker through nvmlDeviceGetComputeRunningProcesses(), which is the process pid on the host machine, but this is different from the process pid in docker. Is there a way to get the process pid in docker instead of the pid on the host machine?

fostiropoulos commented 1 year ago

You would need to run docker with the option --pid host to be able to get the process id, as the host machine and container must share PID space. There are caveats when the host and docker machine OS differ.