From dffd77224cf7f73f3f485cd60fd98cc0b8019078 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:46:34 +0800 Subject: [PATCH 01/14] fix #7896 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/data/ultrasound_confidence_map.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/data/ultrasound_confidence_map.py b/monai/data/ultrasound_confidence_map.py index 5c716b62be..8c7c5326a3 100644 --- a/monai/data/ultrasound_confidence_map.py +++ b/monai/data/ultrasound_confidence_map.py @@ -285,7 +285,7 @@ def _solve_linear_system(self, lap, rhs): lap_sparse = lap.tocsr() ml = ruge_stuben_solver(lap_sparse, coarse_solver="pinv") m = ml.aspreconditioner(cycle="V") - x, _ = cg(lap, rhs, tol=self.cg_tol, maxiter=self.cg_maxiter, M=m) + x, _ = cg(lap, rhs, rtol=self.cg_tol, maxiter=self.cg_maxiter, M=m) else: x = spsolve(lap, rhs) From 8df90610ea808c2ddb280b6f9de5b1cd0257fb70 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:01:33 +0800 Subject: [PATCH 02/14] update version Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- docs/requirements.txt | 2 +- monai/data/ultrasound_confidence_map.py | 8 ++++---- requirements-dev.txt | 2 +- setup.cfg | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index 6caddce666..af67351e53 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,7 +6,7 @@ itk>=5.2 nibabel parameterized scikit-image>=0.19.0 -scipy>=1.7.1 +scipy>=1.14.0 tensorboard commonmark==0.9.1 recommonmark==0.6.0 diff --git a/monai/data/ultrasound_confidence_map.py b/monai/data/ultrasound_confidence_map.py index 8c7c5326a3..c84cf1fd9c 100644 --- a/monai/data/ultrasound_confidence_map.py +++ b/monai/data/ultrasound_confidence_map.py @@ -19,10 +19,10 @@ __all__ = ["UltrasoundConfidenceMap"] cv2, _ = optional_import("cv2") -csc_matrix, _ = optional_import("scipy.sparse", "1.7.1", min_version, "csc_matrix") -spsolve, _ = optional_import("scipy.sparse.linalg", "1.7.1", min_version, "spsolve") -cg, _ = optional_import("scipy.sparse.linalg", "1.7.1", min_version, "cg") -hilbert, _ = optional_import("scipy.signal", "1.7.1", min_version, "hilbert") +csc_matrix, _ = optional_import("scipy.sparse", "1.14.0", min_version, "csc_matrix") +spsolve, _ = optional_import("scipy.sparse.linalg", "1.14.0", min_version, "spsolve") +cg, _ = optional_import("scipy.sparse.linalg", "1.14.0", min_version, "cg") +hilbert, _ = optional_import("scipy.signal", "1.14.0", min_version, "hilbert") ruge_stuben_solver, _ = optional_import("pyamg", "5.0.0", min_version, "ruge_stuben_solver") diff --git a/requirements-dev.txt b/requirements-dev.txt index 1bba930273..6a42040606 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ -r requirements-min.txt pytorch-ignite==0.4.11 gdown>=4.7.3 -scipy>=1.7.1 +scipy>=1.14.0 itk>=5.2 nibabel pillow!=8.3.0 # https://github.com/python-pillow/Pillow/issues/5571 diff --git a/setup.cfg b/setup.cfg index 05bf181c70..9e9c9d33c3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,7 +49,7 @@ all = nibabel ninja scikit-image>=0.14.2 - scipy>=1.7.1 + scipy>=1.14.0 pillow tensorboard gdown>=4.7.3 @@ -92,7 +92,7 @@ ninja = skimage = scikit-image>=0.14.2 scipy = - scipy>=1.7.1 + scipy>=1.14.0 pillow = pillow!=8.3.0 tensorboard = From 1499f1653b080c44b7ef559800348bb94b21393a Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 2 Jul 2024 13:13:46 +0800 Subject: [PATCH 03/14] update version Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- docs/requirements.txt | 2 +- monai/data/ultrasound_confidence_map.py | 8 ++++---- requirements-dev.txt | 2 +- setup.cfg | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index af67351e53..fe415a07b5 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -6,7 +6,7 @@ itk>=5.2 nibabel parameterized scikit-image>=0.19.0 -scipy>=1.14.0 +scipy>=1.12.0; python_version >= '3.9' tensorboard commonmark==0.9.1 recommonmark==0.6.0 diff --git a/monai/data/ultrasound_confidence_map.py b/monai/data/ultrasound_confidence_map.py index c84cf1fd9c..865e4a0a0f 100644 --- a/monai/data/ultrasound_confidence_map.py +++ b/monai/data/ultrasound_confidence_map.py @@ -19,10 +19,10 @@ __all__ = ["UltrasoundConfidenceMap"] cv2, _ = optional_import("cv2") -csc_matrix, _ = optional_import("scipy.sparse", "1.14.0", min_version, "csc_matrix") -spsolve, _ = optional_import("scipy.sparse.linalg", "1.14.0", min_version, "spsolve") -cg, _ = optional_import("scipy.sparse.linalg", "1.14.0", min_version, "cg") -hilbert, _ = optional_import("scipy.signal", "1.14.0", min_version, "hilbert") +csc_matrix, _ = optional_import("scipy.sparse", "1.12.0", min_version, "csc_matrix") +spsolve, _ = optional_import("scipy.sparse.linalg", "1.12.0", min_version, "spsolve") +cg, _ = optional_import("scipy.sparse.linalg", "1.12.0", min_version, "cg") +hilbert, _ = optional_import("scipy.signal", "1.12.0", min_version, "hilbert") ruge_stuben_solver, _ = optional_import("pyamg", "5.0.0", min_version, "ruge_stuben_solver") diff --git a/requirements-dev.txt b/requirements-dev.txt index 6a42040606..ced783443e 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ -r requirements-min.txt pytorch-ignite==0.4.11 gdown>=4.7.3 -scipy>=1.14.0 +scipy>=1.12.0; python_version >= '3.9' itk>=5.2 nibabel pillow!=8.3.0 # https://github.com/python-pillow/Pillow/issues/5571 diff --git a/setup.cfg b/setup.cfg index 9e9c9d33c3..b2b32066ab 100644 --- a/setup.cfg +++ b/setup.cfg @@ -49,7 +49,7 @@ all = nibabel ninja scikit-image>=0.14.2 - scipy>=1.14.0 + scipy>=1.12.0; python_version >= '3.9' pillow tensorboard gdown>=4.7.3 @@ -92,7 +92,7 @@ ninja = skimage = scikit-image>=0.14.2 scipy = - scipy>=1.14.0 + scipy>=1.12.0; python_version >= '3.9' pillow = pillow!=8.3.0 tensorboard = From fb28a3f239b0f08296e0b577ef5c5715deed3d74 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:02:34 +0800 Subject: [PATCH 04/14] use python3.9 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d1e77bb567..d0eed0c0eb 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -130,10 +130,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - name: cache weekly timestamp id: pip-cache run: | From fdb2ce59f30cb834448cec08537d4c52a6516fa2 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Tue, 2 Jul 2024 22:56:28 +0800 Subject: [PATCH 05/14] fix ci Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- tests/test_ultrasound_confidence_map_transform.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/test_ultrasound_confidence_map_transform.py b/tests/test_ultrasound_confidence_map_transform.py index 87c08b3ac3..e5fe33e71d 100644 --- a/tests/test_ultrasound_confidence_map_transform.py +++ b/tests/test_ultrasound_confidence_map_transform.py @@ -21,6 +21,9 @@ from monai.transforms import UltrasoundConfidenceMapTransform from tests.utils import assert_allclose +from monai.utils import optional_import + +_, has_scipy = optional_import("scipy") TEST_INPUT = np.array( [ @@ -482,6 +485,7 @@ ) +@unittest.skipUnless(has_scipy, "Requires scipy") class TestUltrasoundConfidenceMapTransform(unittest.TestCase): def setUp(self): From 458bebc74d31f3a34e8dc0b9e9efe5780d9ddc4f Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:37:58 +0800 Subject: [PATCH 06/14] fix flake8 Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- tests/test_ultrasound_confidence_map_transform.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ultrasound_confidence_map_transform.py b/tests/test_ultrasound_confidence_map_transform.py index e5fe33e71d..1c6b8f7635 100644 --- a/tests/test_ultrasound_confidence_map_transform.py +++ b/tests/test_ultrasound_confidence_map_transform.py @@ -20,8 +20,8 @@ from PIL import Image from monai.transforms import UltrasoundConfidenceMapTransform -from tests.utils import assert_allclose from monai.utils import optional_import +from tests.utils import assert_allclose _, has_scipy = optional_import("scipy") From 2a27ef87f3dd673caad63a2de023c0ce7ec2ff43 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:07:37 +0800 Subject: [PATCH 07/14] fix Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d0eed0c0eb..d45958595d 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -29,10 +29,10 @@ jobs: opt: ["codeformat", "pytype", "mypy"] steps: - uses: actions/checkout@v4 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - name: cache weekly timestamp id: pip-cache run: | @@ -211,10 +211,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Python 3.8 + - name: Set up Python 3.9 uses: actions/setup-python@v5 with: - python-version: '3.8' + python-version: '3.9' - name: cache weekly timestamp id: pip-cache run: | From 80e5b85b4ecf8682aa95433560057dc7ab9da109 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:33:03 +0800 Subject: [PATCH 08/14] temp remove cache Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d45958595d..8231b79f3e 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -36,6 +36,7 @@ jobs: - name: cache weekly timestamp id: pip-cache run: | + rm -rf /opt/hostedtoolcache echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - name: cache for pip uses: actions/cache@v4 From a465441b300ea9890ec6c5e0c30f6ac04c421f0b Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Thu, 4 Jul 2024 21:29:30 +0800 Subject: [PATCH 09/14] try fix Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- tests/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/utils.py b/tests/utils.py index d1939e590b..77b53cebb8 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -475,7 +475,7 @@ def run_process(self, func, local_rank, args, kwargs, results): if self.verbose: os.environ["NCCL_DEBUG"] = "INFO" os.environ["NCCL_DEBUG_SUBSYS"] = "ALL" - os.environ["NCCL_BLOCKING_WAIT"] = str(1) + os.environ["TORCH_NCCL_BLOCKING_WAIT"] = str(1) os.environ["OMP_NUM_THREADS"] = str(1) os.environ["WORLD_SIZE"] = str(self.nproc_per_node * self.nnodes) os.environ["RANK"] = str(self.nproc_per_node * self.node_rank + local_rank) From 5ce2be9600f0aa65318414cd9e295d6d30699b6e Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:41:47 +0800 Subject: [PATCH 10/14] add workaround Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 1d6ae13eec..aae455f58c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ torch>=1.9 -numpy>=1.20,<2.0 +numpy>=1.20,<=1.26.0 From 39fd059d774074ac63079fb53a215372253edfec Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:42:49 +0800 Subject: [PATCH 11/14] fix Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 8231b79f3e..d45958595d 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -36,7 +36,6 @@ jobs: - name: cache weekly timestamp id: pip-cache run: | - rm -rf /opt/hostedtoolcache echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - name: cache for pip uses: actions/cache@v4 From 89cf952bb1488376ead153ce608c313203c03f65 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:26:43 +0800 Subject: [PATCH 12/14] clear cache Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index d45958595d..8231b79f3e 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -36,6 +36,7 @@ jobs: - name: cache weekly timestamp id: pip-cache run: | + rm -rf /opt/hostedtoolcache echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - name: cache for pip uses: actions/cache@v4 From 657861230b6dbf47dee9ddd27079399516666f07 Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Fri, 5 Jul 2024 20:53:44 +0800 Subject: [PATCH 13/14] fix mypy Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- .github/workflows/pythonapp.yml | 2 +- monai/optimizers/lr_finder.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 8231b79f3e..cd6b6ccede 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -36,7 +36,6 @@ jobs: - name: cache weekly timestamp id: pip-cache run: | - rm -rf /opt/hostedtoolcache echo "datew=$(date '+%Y-%V')" >> $GITHUB_OUTPUT - name: cache for pip uses: actions/cache@v4 @@ -46,6 +45,7 @@ jobs: key: ${{ runner.os }}-pip-${{ steps.pip-cache.outputs.datew }} - name: Install dependencies run: | + find /opt/hostedtoolcache/* -maxdepth 0 ! -name 'Python' -exec rm -rf {} \; python -m pip install --upgrade pip wheel python -m pip install -r requirements-dev.txt - name: Lint and type check diff --git a/monai/optimizers/lr_finder.py b/monai/optimizers/lr_finder.py index 045135628d..3467727b96 100644 --- a/monai/optimizers/lr_finder.py +++ b/monai/optimizers/lr_finder.py @@ -15,7 +15,7 @@ import types import warnings from functools import partial -from typing import TYPE_CHECKING, Any, Callable +from typing import TYPE_CHECKING, Any, Callable, Sequence import numpy as np import torch @@ -524,7 +524,7 @@ def plot( # Plot the LR with steepest gradient if steepest_lr: lr_at_steepest_grad, loss_at_steepest_grad = self.get_steepest_gradient(skip_start, skip_end) - if lr_at_steepest_grad is not None: + if lr_at_steepest_grad is not None and loss_at_steepest_grad is not None: ax.scatter( lr_at_steepest_grad, loss_at_steepest_grad, From 3e4d82b9ff023dbbb97c9743ba4fa3207364e0c1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 12:54:23 +0000 Subject: [PATCH 14/14] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- monai/optimizers/lr_finder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/optimizers/lr_finder.py b/monai/optimizers/lr_finder.py index 3467727b96..aa2e4567b3 100644 --- a/monai/optimizers/lr_finder.py +++ b/monai/optimizers/lr_finder.py @@ -15,7 +15,7 @@ import types import warnings from functools import partial -from typing import TYPE_CHECKING, Any, Callable, Sequence +from typing import TYPE_CHECKING, Any, Callable import numpy as np import torch