From 30131dbf24a7d12a41139115c9da5560aec7f355 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 26 Mar 2024 18:09:41 +0800 Subject: [PATCH 1/3] workaround for #7575 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/monai/__init__.py b/monai/__init__.py index 638220f6df..13007e5021 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -83,6 +83,10 @@ from .utils.tf32 import detect_default_tf32 detect_default_tf32() + import torch + + if hasattr(torch.cuda.device_count, "cache_clear"): + torch.cuda.device_count.cache_clear() except BaseException: from .utils.misc import MONAIEnvVars From 8c9c63b8188692d9d211f4a3fb4a6f29c47009bc Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:51:19 +0800 Subject: [PATCH 2/3] Update monai/__init__.py Co-authored-by: Eric Kerfoot <17726042+ericspod@users.noreply.github.com> Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/__init__.py b/monai/__init__.py index 13007e5021..7b244f2b01 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -84,7 +84,7 @@ 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 842e95dbdc1802f433fa4b4bd90e2b7b2e184ebd Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Wed, 27 Mar 2024 10:54:13 +0800 Subject: [PATCH 3/3] address comments Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/monai/__init__.py b/monai/__init__.py index 7b244f2b01..eb05ac993d 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -84,7 +84,8 @@ detect_default_tf32() import torch -# workaround related to https://github.com/Project-MONAI/MONAI/issues/7575 + + # 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: