MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / _find_cuda_home

Function _find_cuda_home

tests/conftest.py:6–31  ·  view source on GitHub ↗

Find a CUDA toolkit installation with nvcc that supports the current GPU.

()

Source from the content-addressed store, hash-verified

4
5
6def _find_cuda_home() -> str | None:
7 """Find a CUDA toolkit installation with nvcc that supports the current GPU."""
8 # Respect explicit CUDA_HOME
9 if os.environ.get("CUDA_HOME"):
10 return os.environ["CUDA_HOME"]
11
12 # Check /usr/local/cuda symlink (standard CUDA toolkit location)
13 if os.path.isfile("/usr/local/cuda/bin/nvcc"):
14 return "/usr/local/cuda"
15
16 # Search /usr/local/cuda-* directories (prefer highest version)
17 import glob
18
19 candidates = sorted(glob.glob("/usr/local/cuda-*/bin/nvcc"), reverse=True)
20 for nvcc_path in candidates:
21 cuda_home = os.path.dirname(os.path.dirname(nvcc_path))
22 return cuda_home
23
24 # Fall back to system nvcc location
25 nvcc = shutil.which("nvcc")
26 if nvcc:
27 real = os.path.realpath(nvcc)
28 bin_dir = os.path.dirname(real)
29 return os.path.dirname(bin_dir)
30
31 return None
32
33
34def _check_nvcc_supports_gpu(cuda_home: str) -> None:

Callers 1

conftest.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected