Unverified Commit b0b5347a authored by Degeneracy-Evil's avatar Degeneracy-Evil Committed by GitHub
Browse files

[Bugfix] Add NVIDIA HPC SDK support in CUDA detection (#974) (#976)



* [Bugfix] Add NVIDIA HPC SDK support in CUDA detection (#974)

Enhanced CUDA detection to recognize NVIDIA HPC SDK installations:
- Added path check for nvhpc in nvcc binary path
- Added fallback scan for default nvhpc paths:
  /opt/nvidia/hpc_sdk/Linux_x86_64
- Maintained backward compatibility with standard CUDA installations

Verification:
- Tested on Ubuntu 24.04 with NVIDIA HPC SDK 25.7
- Confirmed detection works without manual CUDA_HOME or CUDA_PATH setting

Fixes #974

* [Bugfix] Fix CUDA home detection logic

* [Bugfix] Safely handle None cuda_home during CUDA detection

Adds a check for None before validating the CUDA home path to prevent errors when the path is not set.

* [Bugfix] Fix CUDA detection edge cases in nvhpc support (#974)

- Improved nvhpc path detection logic
- Added None check for cuda_home to avoid crashes
- Maintained existing CUDA installation compatibility

Fixes #974

* chore: rerun CI

---------
Co-authored-by: default avatarNaNExist <138002947+NaNExist@users.noreply.github.com>
parent 05507037
...@@ -30,17 +30,34 @@ def _find_cuda_home() -> str: ...@@ -30,17 +30,34 @@ def _find_cuda_home() -> str:
if cuda_home is None: if cuda_home is None:
# Guess #2 # Guess #2
nvcc_path = shutil.which("nvcc") nvcc_path = shutil.which("nvcc")
if nvcc_path is not None and "cuda" in nvcc_path.lower(): if nvcc_path is not None:
cuda_home = os.path.dirname(os.path.dirname(nvcc_path)) # Standard CUDA pattern
if "cuda" in nvcc_path.lower():
cuda_home = os.path.dirname(os.path.dirname(nvcc_path))
# NVIDIA HPC SDK pattern
elif "hpc_sdk" in nvcc_path.lower():
# Navigate to the root directory of nvhpc
cuda_home = os.path.dirname(os.path.dirname(os.path.dirname(nvcc_path)))
# Generic fallback for non-standard or symlinked installs
else:
cuda_home = os.path.dirname(os.path.dirname(nvcc_path))
else: else:
# Guess #3 # Guess #3
if sys.platform == 'win32': if sys.platform == 'win32':
cuda_homes = glob.glob('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v*.*') cuda_homes = glob.glob('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v*.*')
cuda_home = '' if len(cuda_homes) == 0 else cuda_homes[0] cuda_home = '' if len(cuda_homes) == 0 else cuda_homes[0]
else: else:
cuda_home = '/usr/local/cuda' # Linux/macOS
if not os.path.exists(cuda_home): if os.path.exists('/usr/local/cuda'):
cuda_home = '/usr/local/cuda'
elif os.path.exists('/opt/nvidia/hpc_sdk/Linux_x86_64'):
cuda_home = '/opt/nvidia/hpc_sdk/Linux_x86_64'
# Validate found path
if cuda_home is None or not os.path.exists(cuda_home):
cuda_home = None cuda_home = None
return cuda_home if cuda_home is not None else "" return cuda_home if cuda_home is not None else ""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment