Utility function to find CUDA path Returns ------- path : str Path to CUDA root.
()
| 699 | |
| 700 | |
| 701 | def find_cuda_path(): |
| 702 | """Utility function to find CUDA path |
| 703 | |
| 704 | Returns |
| 705 | ------- |
| 706 | path : str |
| 707 | Path to CUDA root. |
| 708 | """ |
| 709 | if "CUDA_PATH" in os.environ: |
| 710 | return os.environ["CUDA_PATH"] |
| 711 | cmd = ["which", "nvcc"] |
| 712 | proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) |
| 713 | (out, _) = proc.communicate() |
| 714 | out = out.decode("utf-8", errors="replace") |
| 715 | if proc.returncode == 0: |
| 716 | return os.path.realpath(os.path.join(str(out).strip(), "../..")) |
| 717 | cuda_path = "/usr/local/cuda" |
| 718 | if os.path.exists(os.path.join(cuda_path, "bin/nvcc")): |
| 719 | return cuda_path |
| 720 | raise RuntimeError("Cannot find CUDA path") |
| 721 | |
| 722 | |
| 723 | def get_cuda_version(cuda_path=None): |
no test coverage detected
searching dependent graphs…