Skip to content

Commit 15b3a6b

Browse files
committed
fix ci
Signed-off-by: YunLiu <[email protected]>
2 parents ebeaeab + 8631db7 commit 15b3a6b

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

monai/utils/module.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -652,15 +652,18 @@ def compute_capabilities_after(major: int, minor: int = 0, current_ver_string: s
652652
True if the current system GPU CUDA compute capability is greater than or equal to the specified version.
653653
"""
654654
if current_ver_string is None:
655+
cuda_available = torch.cuda.is_available()
655656
pynvml, has_pynvml = optional_import("pynvml")
656657
if not has_pynvml: # assuming that the user has Ampere and later GPU
657658
return True
658-
659-
pynvml.nvmlInit()
660-
handle = pynvml.nvmlDeviceGetHandleByIndex(0) # get the first GPU
661-
major_c, minor_c = pynvml.nvmlDeviceGetCudaComputeCapability(handle)
662-
current_ver_string = f"{major_c}.{minor_c}"
663-
pynvml.nvmlShutdown()
659+
if not cuda_available:
660+
return False
661+
else:
662+
pynvml.nvmlInit()
663+
handle = pynvml.nvmlDeviceGetHandleByIndex(0) # get the first GPU
664+
major_c, minor_c = pynvml.nvmlDeviceGetCudaComputeCapability(handle)
665+
current_ver_string = f"{major_c}.{minor_c}"
666+
pynvml.nvmlShutdown()
664667

665668
ver, has_ver = optional_import("packaging.version", name="parse")
666669
if has_ver:

0 commit comments

Comments
 (0)