How to get the MIG UUID of the current device in python?

I want to be able to get the MIG UUID of the visible device in python when using PyTorch. Is there a way to get this info? From Nvidia documentation I saw that a process sees only 1 MIG instance, so I just want to be able get the UUID for it.

You could call the internal torch.cuda._raw_device_uuid_nvml() method or re-implement a custom one if needed. Note that internal methods can easily break and do not guarantee to have a stable interface.