Detect NVCC (CUDA compiler) with advanced cross-platform support. Checks: 1. Configured path (from config) 2. PATH environment variable 3. CUDA_PATH environment variable 4. Common installation locations 5. Extracts version information
(self)
| 61 | # ============================================================================ |
| 62 | |
| 63 | def detect_nvcc(self) -> ToolInfo: |
| 64 | """ |
| 65 | Detect NVCC (CUDA compiler) with advanced cross-platform support. |
| 66 | |
| 67 | Checks: |
| 68 | 1. Configured path (from config) |
| 69 | 2. PATH environment variable |
| 70 | 3. CUDA_PATH environment variable |
| 71 | 4. Common installation locations |
| 72 | 5. Extracts version information |
| 73 | |
| 74 | Returns: |
| 75 | ToolInfo with availability, path, version |
| 76 | """ |
| 77 | if 'nvcc' in self._cache: |
| 78 | return self._cache['nvcc'] |
| 79 | |
| 80 | # Check configured path first (highest priority) |
| 81 | if 'nvcc' in self.config_paths and self.config_paths['nvcc']: |
| 82 | nvcc_configured = Path(self.config_paths['nvcc']) |
| 83 | if nvcc_configured.exists(): |
| 84 | version = self._get_nvcc_version(str(nvcc_configured)) |
| 85 | info = ToolInfo( |
| 86 | available=True, |
| 87 | path=str(nvcc_configured), |
| 88 | version=version |
| 89 | ) |
| 90 | self._cache['nvcc'] = info |
| 91 | return info |
| 92 | |
| 93 | # Check PATH (fast auto-detection) |
| 94 | nvcc_path = shutil.which('nvcc') |
| 95 | |
| 96 | if nvcc_path: |
| 97 | version = self._get_nvcc_version(nvcc_path) |
| 98 | info = ToolInfo( |
| 99 | available=True, |
| 100 | path=nvcc_path, |
| 101 | version=version |
| 102 | ) |
| 103 | self._cache['nvcc'] = info |
| 104 | return info |
| 105 | |
| 106 | # Check CUDA_PATH environment variable |
| 107 | cuda_path = os.getenv('CUDA_PATH') |
| 108 | if cuda_path: |
| 109 | nvcc_bin = Path(cuda_path) / 'bin' / ('nvcc.exe' if self.platform == 'Windows' else 'nvcc') |
| 110 | if nvcc_bin.exists(): |
| 111 | version = self._get_nvcc_version(str(nvcc_bin)) |
| 112 | info = ToolInfo( |
| 113 | available=True, |
| 114 | path=str(nvcc_bin), |
| 115 | version=version |
| 116 | ) |
| 117 | self._cache['nvcc'] = info |
| 118 | return info |
| 119 | |
| 120 | # Check common installation locations |
no test coverage detected