From 2e75e2d076c67a4598fc09157e4513c23b28b142 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 11 Apr 2026 02:20:20 +0200 Subject: [PATCH] fix: handle None from cupy.cuda.get_cuda_path() in cuda_launch cupy.cuda.get_cuda_path() can return None when CUDA_HOME is not set and cupy can't auto-detect it. Fall back to /usr/local/cuda. Co-Authored-By: Claude Opus 4.6 --- .../generalizable_INR/modules/softsplat.py | 13 ++++++++----- sgm_vfi_arch/softsplat.py | 8 +++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gimm_vfi_arch/generalizable_INR/modules/softsplat.py b/gimm_vfi_arch/generalizable_INR/modules/softsplat.py index f8139d3..60eaec1 100644 --- a/gimm_vfi_arch/generalizable_INR/modules/softsplat.py +++ b/gimm_vfi_arch/generalizable_INR/modules/softsplat.py @@ -268,11 +268,14 @@ _cuda_launch_cache = {} @torch.compiler.disable() def cuda_launch(strKey: str): if strKey not in _cuda_launch_cache: - try: - os.environ.setdefault("CUDA_HOME", cupy.cuda.get_cuda_path()) - except Exception: - if "CUDA_HOME" not in os.environ: - raise RuntimeError("'CUDA_HOME' not set, unable to find cuda-toolkit installation.") + if "CUDA_HOME" not in os.environ: + try: + cuda_path = cupy.cuda.get_cuda_path() + except Exception: + cuda_path = None + if cuda_path is None: + cuda_path = "/usr/local/cuda" + os.environ["CUDA_HOME"] = cuda_path strKernel = objCudacache[strKey]["strKernel"] strFunction = objCudacache[strKey]["strFunction"] _cuda_launch_cache[strKey] = cupy.RawModule( diff --git a/sgm_vfi_arch/softsplat.py b/sgm_vfi_arch/softsplat.py index f01f5b0..ad2d293 100644 --- a/sgm_vfi_arch/softsplat.py +++ b/sgm_vfi_arch/softsplat.py @@ -224,7 +224,13 @@ _cuda_launch_cache = {} def cuda_launch(strKey:str): if strKey not in _cuda_launch_cache: if 'CUDA_HOME' not in os.environ: - os.environ['CUDA_HOME'] = cupy.cuda.get_cuda_path() + try: + cuda_path = cupy.cuda.get_cuda_path() + except Exception: + cuda_path = None + if cuda_path is None: + cuda_path = '/usr/local/cuda' + os.environ['CUDA_HOME'] = cuda_path _cuda_launch_cache[strKey] = cupy.RawKernel( objCudacache[strKey]['strKernel'], objCudacache[strKey]['strFunction'],