Skip to content

Commit

Permalink
Remove device count cache when import monai (#7581)
Browse files Browse the repository at this point in the history
workaround for #7575


### Types of changes
<!--- Put an `x` in all the boxes that apply, and remove the not
applicable items -->
- [x] Non-breaking change (fix or new feature that would not break
existing functionality).
- [ ] Breaking change (fix or new feature that would cause existing
functionality to change).
- [ ] New tests added to cover the changes.
- [ ] Integration tests passed locally by running `./runtests.sh -f -u
--net --coverage`.
- [ ] Quick tests passed locally by running `./runtests.sh --quick
--unittests --disttests`.
- [ ] In-line docstrings updated.
- [ ] Documentation updated, tested `make html` command in the `docs/`
folder.

---------

Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com>
Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com>
  • Loading branch information
KumoLiu and ericspod authored Mar 27, 2024
1 parent e5bebfc commit 2716b6a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions monai/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
from .utils.tf32 import detect_default_tf32

detect_default_tf32()
import torch

# workaround related to https://github.com/Project-MONAI/MONAI/issues/7575
if hasattr(torch.cuda.device_count, "cache_clear"):
torch.cuda.device_count.cache_clear()
except BaseException:
from .utils.misc import MONAIEnvVars

Expand Down

0 comments on commit 2716b6a

Please sign in to comment.