MCPcopy Create free account
hub / github.com/apache/tvm / get_cuda_version

Function get_cuda_version

python/tvm/support/nvcc.py:723–762  ·  view source on GitHub ↗

Utility function to get CUDA version Parameters ---------- cuda_path : Optional[str] Path to CUDA root. If None is passed, will use `find_cuda_path()` as default. Returns ------- version : float The CUDA version

(cuda_path=None)

Source from the content-addressed store, hash-verified

721
722
723def get_cuda_version(cuda_path=None):
724 """Utility function to get CUDA version
725
726 Parameters
727 ----------
728 cuda_path : Optional[str]
729
730 Path to CUDA root. If None is passed, will use
731 `find_cuda_path()` as default.
732
733 Returns
734 -------
735 version : float
736 The CUDA version
737
738 """
739 if cuda_path is None:
740 cuda_path = find_cuda_path()
741
742 version_file_path = os.path.join(cuda_path, "version.txt")
743 if not os.path.exists(version_file_path):
744 # Debian/Ubuntu repackaged CUDA path
745 version_file_path = os.path.join(cuda_path, "lib", "cuda", "version.txt")
746 try:
747 with open(version_file_path) as f:
748 version_str = f.read().strip().split()[-1]
749 return tuple(int(field) for field in version_str.split("."))
750 except FileNotFoundError:
751 pass
752
753 cmd = [os.path.join(cuda_path, "bin", "nvcc"), "--version"]
754 proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
755 (out, _) = proc.communicate()
756 out = out.decode("utf-8", errors="replace")
757 if proc.returncode == 0:
758 release_line = next(line for line in out.split("\n") if "release" in line)
759 release_fields = [s.strip() for s in release_line.split(",")]
760 version_str = next(f[1:] for f in release_fields if f.startswith("V"))
761 return tuple(int(field) for field in version_str.split("."))
762 raise RuntimeError("Cannot read CUDA version file")
763
764
765def find_nvshmem_paths() -> tuple[str, str]:

Callers 3

find_libdevice_pathFunction · 0.85
have_cudagraphFunction · 0.85

Calls 6

find_cuda_pathFunction · 0.85
tupleFunction · 0.85
readMethod · 0.65
joinMethod · 0.45
splitMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…