|
25 | 25 | from torch.torch_version import TorchVersion |
26 | 26 |
|
27 | 27 | from setuptools.command.build_ext import build_ext |
28 | | -import packaging.version |
| 28 | +from pkg_resources import packaging # type: ignore[attr-defined] |
29 | 29 |
|
30 | 30 | IS_WINDOWS = sys.platform == 'win32' |
31 | 31 | IS_MACOS = sys.platform.startswith('darwin') |
@@ -404,9 +404,6 @@ def _check_cuda_version(compiler_name: str, compiler_version: TorchVersion) -> N |
404 | 404 |
|
405 | 405 | cuda_str_version = cuda_version.group(1) |
406 | 406 | cuda_ver = packaging.version.parse(cuda_str_version) |
407 | | - if torch.version.cuda is None: |
408 | | - return |
409 | | - |
410 | 407 | torch_cuda_version = packaging.version.parse(torch.version.cuda) |
411 | 408 | if cuda_ver != torch_cuda_version: |
412 | 409 | # major/minor attributes are only available in setuptools>=49.4.0 |
@@ -2348,7 +2345,8 @@ def sanitize_flags(flags): |
2348 | 2345 | # Compilation will work on earlier CUDA versions but header file |
2349 | 2346 | # dependencies are not correctly computed. |
2350 | 2347 | required_cuda_version = packaging.version.parse('11.0') |
2351 | | - if torch.version.cuda is not None and packaging.version.parse(torch.version.cuda) >= required_cuda_version: |
| 2348 | + has_cuda_version = torch.version.cuda is not None |
| 2349 | + if has_cuda_version and packaging.version.parse(torch.version.cuda) >= required_cuda_version: |
2352 | 2350 | cuda_compile_rule.append(' depfile = $out.d') |
2353 | 2351 | cuda_compile_rule.append(' deps = gcc') |
2354 | 2352 | # Note: non-system deps with nvcc are only supported |
|
0 commit comments