nvidiamulti-gpunvidia-smi

How do I check which of my NVIDIA GPUs is used for display?


I'm on a system with multiple NVIDIA GPUs. One or more of them may - or may not - be used to drive a physical monitor. In my compute work, I want to avoid using that one (or more).

How can I, programmatically, check which GPUs are used for display?

If there's no robust way of doing that, I'll settle for getting those GPUs which are used by an Xorg process (which is what nvidia-smi gives me on the command-line)


Solution

  • In case you want to use the same process, you can check the NVML API functions nvmlDeviceGetDisplayActive and nvmlDeviceGetDisplayMode. Specifically,

    Link to documentation