How to get all available devices for CuPy?

30 Views Asked by At

How can I get all available devices for CuPy? I'm looking to write a version of this for CuPy:

if is_torch(xp):
    devices = ['cpu']
    import torch  # type: ignore[import]
    num_cuda = torch.cuda.device_count()
    for i in range(0, num_cuda):
        devices += [f'cuda:{i}']
    if torch.backends.mps.is_available():
        devices += ['mps']
    return devices 

0

There are 0 best solutions below