Skip to content

delete set_visible_devices? #2167

@rijobro

Description

@rijobro

Describe the bug
We have a function called set_visible_devices, but I can't see it used anywhere, it's not tested, and I'm not convinced it works... I think it should be deleted.

If we set the visible device to 0 before importing monai (and therefore torch), and then requesting device 1, the following fails, as expected:

import os
os.environ['CUDA_VISIBLE_DEVICES']='0'
import torch
a=torch.rand((1), device='cuda:1')
print(a.device)

output:

RuntimeError: CUDA error: invalid device ordinal

However, when setting the device after importing monai (and therefore torch), it seems to be ignored as the following is fine:

import monai
monai.config.deviceconfig.set_visible_devices(0)
import torch
a=torch.rand((1), device='cuda:1')
print(a.device)

output:

cuda:1

I therefore don't see a scenario in which set_visible_devices can function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions