-
Notifications
You must be signed in to change notification settings - Fork 1.5k
delete set_visible_devices? #2167
Copy link
Copy link
Closed
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels