Skip to content

Commit aef9e43

Browse files
Revert "Replaced deprecated pkg_resources.packaging with packaging module (#113023)"
This reverts commit 81ea7a4. Reverted #113023 on behalf of https://github.com/atalman due to breaks nightlies ([comment](#113023 (comment)))
1 parent b30f178 commit aef9e43

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

tools/dynamo/verify_dynamo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import traceback
66
import warnings
77

8-
import packaging.version
8+
from pkg_resources import packaging
99

1010
MIN_CUDA_VERSION = packaging.version.parse("11.6")
1111
MIN_ROCM_VERSION = packaging.version.parse("5.4")

torch/utils/cpp_extension.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from torch.torch_version import TorchVersion
2626

2727
from setuptools.command.build_ext import build_ext
28-
import packaging.version
28+
from pkg_resources import packaging # type: ignore[attr-defined]
2929

3030
IS_WINDOWS = sys.platform == 'win32'
3131
IS_MACOS = sys.platform.startswith('darwin')
@@ -404,9 +404,6 @@ def _check_cuda_version(compiler_name: str, compiler_version: TorchVersion) -> N
404404

405405
cuda_str_version = cuda_version.group(1)
406406
cuda_ver = packaging.version.parse(cuda_str_version)
407-
if torch.version.cuda is None:
408-
return
409-
410407
torch_cuda_version = packaging.version.parse(torch.version.cuda)
411408
if cuda_ver != torch_cuda_version:
412409
# major/minor attributes are only available in setuptools>=49.4.0
@@ -2348,7 +2345,8 @@ def sanitize_flags(flags):
23482345
# Compilation will work on earlier CUDA versions but header file
23492346
# dependencies are not correctly computed.
23502347
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:
23522350
cuda_compile_rule.append(' depfile = $out.d')
23532351
cuda_compile_rule.append(' deps = gcc')
23542352
# Note: non-system deps with nvcc are only supported

0 commit comments

Comments
 (0)