diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 8627c0ece64..fe826456c79 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: - python-version: "3.8" + python-version: "3.11" - run: | bash ./tests/run_code_style.sh install bash ./tests/run_code_style.sh fmt diff --git a/.github/workflows/hvd-tests.yml b/.github/workflows/hvd-tests.yml index 2733250faf8..9a6d909d3cd 100644 --- a/.github/workflows/hvd-tests.yml +++ b/.github/workflows/hvd-tests.yml @@ -28,7 +28,7 @@ jobs: timeout-minutes: 60 strategy: matrix: - python-version: [3.8] + python-version: ["3.11"] pytorch-channel: [pytorch] steps: @@ -64,7 +64,20 @@ jobs: #install other dependencies pip install torch torchvision --index-url https://download.pytorch.org/whl/cpu pip install -r requirements-dev.txt - pip install horovod + + # Install Horovod from source and apply a patch to build with recent pytorch + # We can't use pip install as build-env can't find pytorch and + # `--no-build-isolation` does not work with horovod setup.py + git clone --recursive https://github.com/horovod/horovod.git /tmp/horovod + cd /tmp/horovod + sed -i "s/CMAKE_CXX_STANDARD 14/CMAKE_CXX_STANDARD 17/g" CMakeLists.txt + sed -i "s/CMAKE_CXX_STANDARD 14/CMAKE_CXX_STANDARD 17/g" horovod/torch/CMakeLists.txt + HOROVOD_WITH_PYTORCH=1 python setup.py install + cd - + # test the installation: + python -c "import horovod.torch as hvd; hvd.mpi_ops.Sum" + + # Install ignite python setup.py install # Download MNIST: https://github.com/pytorch/ignite/issues/1737 diff --git a/.github/workflows/mps-tests.yml b/.github/workflows/mps-tests.yml index 4cdd01f5a21..ac63aa725e2 100644 --- a/.github/workflows/mps-tests.yml +++ b/.github/workflows/mps-tests.yml @@ -34,7 +34,7 @@ jobs: mps-tests: strategy: matrix: - python-version: [3.8] + python-version: [3.11] pytorch-channel: ["pytorch"] skip-distrib-tests: [1] fail-fast: false diff --git a/.github/workflows/pytorch-version-tests.yml b/.github/workflows/pytorch-version-tests.yml index f268669158e..0ea40866aba 100644 --- a/.github/workflows/pytorch-version-tests.yml +++ b/.github/workflows/pytorch-version-tests.yml @@ -15,15 +15,12 @@ jobs: max-parallel: 5 fail-fast: false matrix: + # Here we keep python 3.8 tests until the end of the 2024 and + # will drop python version and related pytorch versions python-version: [3.8, 3.9, "3.10"] pytorch-version: - [2.3.1, 2.2.2, 2.1.2, 2.0.1, 1.13.1, 1.12.1, 1.10.0, 1.8.1, 1.5.1] + [2.3.1, 2.2.2, 2.1.2, 2.0.1, 1.13.1, 1.12.1, 1.10.0, 1.8.1] exclude: - - pytorch-version: 1.5.1 - python-version: 3.9 - - pytorch-version: 1.5.1 - python-version: "3.10" - # disabling python 3.9 support with PyTorch 1.7.1 and 1.8.1, to stop repeated pytorch-version test fail. # https://github.com/pytorch/ignite/issues/2383 - pytorch-version: 1.8.1 @@ -72,6 +69,13 @@ jobs: shell: bash -l {0} run: | conda install pytorch=${{ matrix.pytorch-version }} torchvision cpuonly python=${{ matrix.python-version }} -c pytorch + + # We should install numpy<2.0 for pytorch<2.3 + numpy_one_pth_version=$(python -c "import torch; print(float('.'.join(torch.__version__.split('.')[:2])) < 2.3)") + if [ "${numpy_one_pth_version}" == "True" ]; then + pip install -U "numpy<2.0" + fi + pip install -r requirements-dev.txt python setup.py install diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index feacc642ffb..2153f74c361 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -40,18 +40,18 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.9", "3.10", "3.11", "3.12"] pytorch-channel: [pytorch, pytorch-nightly] include: # includes a single build on windows - os: windows-latest pytorch-channel: pytorch - python-version: 3.9 + python-version: 3.11 skip-distrib-tests: 1 # includes a single build on macosx - os: macos-latest pytorch-channel: pytorch - python-version: 3.9 + python-version: 3.11 skip-distrib-tests: 1 steps: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fd41e6abf86..eabbef21151 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -61,7 +61,7 @@ into the following categories: - Create an isolated conda environment for pytorch-ignite: ```bash -conda create -n pytorch-ignite-dev python=3.8 +conda create -n pytorch-ignite-dev python=3.11 ``` - Activate the newly created environment: diff --git a/ignite/handlers/neptune_logger.py b/ignite/handlers/neptune_logger.py index 092d1f81574..79157dddbf9 100644 --- a/ignite/handlers/neptune_logger.py +++ b/ignite/handlers/neptune_logger.py @@ -166,15 +166,7 @@ def __setitem__(self, key: str, val: Any) -> Any: def __init__(self, api_token: Optional[str] = None, project: Optional[str] = None, **kwargs: Any) -> None: try: - try: - # neptune-client<1.0.0 package structure - with warnings.catch_warnings(): - # ignore the deprecation warnings - warnings.simplefilter("ignore") - import neptune.new as neptune - except ImportError: - # neptune>=1.0.0 package structure - import neptune + import neptune except ImportError: raise ModuleNotFoundError( "This contrib module requires the Neptune client library to be installed. " diff --git a/ignite/metrics/hsic.py b/ignite/metrics/hsic.py index a35d47f258b..2967db19e4f 100644 --- a/ignite/metrics/hsic.py +++ b/ignite/metrics/hsic.py @@ -134,6 +134,7 @@ def update(self, output: Sequence[Tensor]) -> None: vx: Union[Tensor, float] if self.sigma_x < 0: + # vx = torch.quantile(dxx, 0.5) vx = torch.quantile(dxx, 0.5) else: vx = self.sigma_x**2 diff --git a/tests/ignite/metrics/test_hsic.py b/tests/ignite/metrics/test_hsic.py index 6ee4237b96e..57af5fa2862 100644 --- a/tests/ignite/metrics/test_hsic.py +++ b/tests/ignite/metrics/test_hsic.py @@ -1,3 +1,4 @@ +import math from typing import Tuple import numpy as np @@ -74,7 +75,7 @@ def test_case(request) -> Tuple[Tensor, Tensor, int]: N = 200 b = 20 x = torch.randn(N, 5) - y = x @ torch.normal(0.0, torch.pi, size=(5, 3)) + y = x @ torch.normal(0.0, math.pi, size=(5, 3)) y = ( torch.stack([torch.sin(y[:, 0]), torch.cos(y[:, 1]), torch.exp(y[:, 2])], dim=1) + torch.randn_like(y) * 1e-4