From c1b4b3c62ea304d034f3373b409211fcaaad02e4 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Mon, 6 Feb 2023 22:32:42 +0100 Subject: [PATCH 1/6] use base version --- src/lightning/pytorch/utilities/imports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lightning/pytorch/utilities/imports.py b/src/lightning/pytorch/utilities/imports.py index 24491db54574b..1fa5996d052f1 100644 --- a/src/lightning/pytorch/utilities/imports.py +++ b/src/lightning/pytorch/utilities/imports.py @@ -21,7 +21,7 @@ _PYTHON_GREATER_EQUAL_3_8_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 8) _PYTHON_GREATER_EQUAL_3_10_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 10) # duplicated from fabric because HPU is patching it below -_TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0") +_TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0", use_base_version=True) _TORCHMETRICS_GREATER_EQUAL_0_9_1 = RequirementCache("torchmetrics>=0.9.1") _HABANA_FRAMEWORK_AVAILABLE = package_available("habana_frameworks") From fb718044b4487e7c5b3eb24cd4080ca4f9cfab70 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Mon, 6 Feb 2023 22:34:57 +0100 Subject: [PATCH 2/6] use base version in other definitions too --- src/lightning/fabric/utilities/imports.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lightning/fabric/utilities/imports.py b/src/lightning/fabric/utilities/imports.py index a58a940152bbf..dd952b920a7b4 100644 --- a/src/lightning/fabric/utilities/imports.py +++ b/src/lightning/fabric/utilities/imports.py @@ -25,6 +25,6 @@ # 2. The inspection mode via `python -i`: https://stackoverflow.com/a/6879085/1162383 _IS_INTERACTIVE = hasattr(sys, "ps1") or bool(sys.flags.interactive) -_TORCH_GREATER_EQUAL_1_12 = compare_version("torch", operator.ge, "1.12.0") -_TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0") +_TORCH_GREATER_EQUAL_1_12 = compare_version("torch", operator.ge, "1.12.0", use_base_version=True) +_TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0", use_base_version=True) _TORCH_GREATER_EQUAL_2_0 = compare_version("torch", operator.ge, "2.0.0", use_base_version=True) From 157a76f03feecb65055e313a1c1b34a6cf99d5f1 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Mon, 6 Feb 2023 22:39:13 +0100 Subject: [PATCH 3/6] changelog --- src/lightning/pytorch/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning/pytorch/CHANGELOG.md b/src/lightning/pytorch/CHANGELOG.md index 6402d001c1e20..1d7a63c81fb79 100644 --- a/src/lightning/pytorch/CHANGELOG.md +++ b/src/lightning/pytorch/CHANGELOG.md @@ -222,6 +222,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed the batch_sampler reference for DataLoaders wrapped with XLA's MpDeviceLoader ([#16571](https://github.com/Lightning-AI/lightning/pull/16571)) +- Fixed an issue with comparing torch versions when using a version of torch built from source ([#16657](https://github.com/Lightning-AI/lightning/pull/16657)) + + ## [1.9.0] - 2023-01-17 ### Added From 2e1b84047d9f5ce043c139582d30c4c039b36608 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Fri, 3 Mar 2023 16:09:53 +0100 Subject: [PATCH 4/6] add comment --- src/lightning/fabric/utilities/imports.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lightning/fabric/utilities/imports.py b/src/lightning/fabric/utilities/imports.py index 527616ddac8d9..85be277f35bb9 100644 --- a/src/lightning/fabric/utilities/imports.py +++ b/src/lightning/fabric/utilities/imports.py @@ -25,6 +25,9 @@ # 2. The inspection mode via `python -i`: https://stackoverflow.com/a/6879085/1162383 _IS_INTERACTIVE = hasattr(sys, "ps1") or bool(sys.flags.interactive) +# We use "base_version" for non-nightly builds as well, because some environments like NVIDIA's PyTorch dockers +# install PyTorch from source at a commit that doesn't align with the released version tag. +# See: https://github.com/Lightning-AI/lightning/issues/16644 _TORCH_GREATER_EQUAL_1_12 = compare_version("torch", operator.ge, "1.12.0", use_base_version=True) _TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0", use_base_version=True) _TORCH_GREATER_EQUAL_2_0 = compare_version("torch", operator.ge, "2.0.0", use_base_version=True) From bffbcc41b2b111a8ac09513d3ccd2f9f6fa216d7 Mon Sep 17 00:00:00 2001 From: awaelchli Date: Fri, 3 Mar 2023 16:10:40 +0100 Subject: [PATCH 5/6] changelog --- src/lightning/pytorch/CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lightning/pytorch/CHANGELOG.md b/src/lightning/pytorch/CHANGELOG.md index d726ff579d069..c878f1d845a35 100644 --- a/src/lightning/pytorch/CHANGELOG.md +++ b/src/lightning/pytorch/CHANGELOG.md @@ -396,6 +396,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an issue where `DistributedSampler.set_epoch` wasn't getting called during `trainer.predict` ([#16785](https://github.com/Lightning-AI/lightning/pull/16785), [#16826](https://github.com/Lightning-AI/lightning/pull/16826)) +- Fixed an issue with comparing torch versions when using a version of torch built from source ([#16657](https://github.com/Lightning-AI/lightning/pull/16657)) + + ## [1.9.4] - 2023-03-01 ### Added @@ -437,9 +440,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed an import error when `torch.distributed` is not available ([#16658](https://github.com/Lightning-AI/lightning/pull/16658)) -- Fixed an issue with comparing torch versions when using a version of torch built from source ([#16657](https://github.com/Lightning-AI/lightning/pull/16657)) - - ## [1.9.0] - 2023-01-17 ### Added From 65d73ba71ce4fa85942488d8d61b943316717090 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Mon, 6 Mar 2023 14:53:31 +0100 Subject: [PATCH 6/6] Update src/lightning/pytorch/utilities/imports.py --- src/lightning/pytorch/utilities/imports.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lightning/pytorch/utilities/imports.py b/src/lightning/pytorch/utilities/imports.py index 1d606aa58df91..0b984280865c2 100644 --- a/src/lightning/pytorch/utilities/imports.py +++ b/src/lightning/pytorch/utilities/imports.py @@ -21,7 +21,6 @@ _PYTHON_GREATER_EQUAL_3_8_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 8) _PYTHON_GREATER_EQUAL_3_10_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 10) _PYTHON_GREATER_EQUAL_3_11_0 = (sys.version_info.major, sys.version_info.minor) >= (3, 11) -# duplicated from fabric because HPU is patching it below _TORCH_GREATER_EQUAL_1_13 = compare_version("torch", operator.ge, "1.13.0", use_base_version=True) _TORCHMETRICS_GREATER_EQUAL_0_9_1 = RequirementCache("torchmetrics>=0.9.1") _TORCHMETRICS_GREATER_EQUAL_0_11 = compare_version("torchmetrics", operator.ge, "0.11.0") # using new API with task