Skip to content

CUDA_VISIBLE_DEVICES setting ignored after import monai #7407

@KumoLiu

Description

@KumoLiu

Describe the bug
CUDA_VISIBLE_DEVICES setting ignored after import monai

To Reproduce

import os
import torch
print('before import monai:', torch.cuda.device_count())
import monai

os.environ["CUDA_VISIBLE_DEVICES"] = "0"
print('after import monai:')
torch.cuda.set_device(1) # should failed

Expected behavior
CUDA_VISIBLE_DEVICES setting should not ignored after import monai

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions