From 104a360f953b5d720b3eb8f5b1a0546540e5e391 Mon Sep 17 00:00:00 2001 From: Wenqi Li <831580+wyli@users.noreply.github.com> Date: Thu, 23 Mar 2023 12:44:44 +0000 Subject: [PATCH] 6166 drop py37 and torch 1.8 (#6227) Fixes #6166 ### Description - reviewed the package metadata - keep testing and code logic ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [x] Documentation updated, tested `make html` command in the `docs/` folder. --------- Signed-off-by: Wenqi Li --- .github/workflows/cron.yml | 44 +---------------------- .github/workflows/pythonapp-gpu.yml | 16 ++------- .github/workflows/pythonapp-min.yml | 16 +++------ .github/workflows/pythonapp.yml | 2 +- .github/workflows/release.yml | 4 +-- .github/workflows/setupapp.yml | 2 +- .readthedocs.yml | 2 +- CONTRIBUTING.md | 2 +- docs/images/python.svg | 2 +- docs/requirements.txt | 2 +- docs/source/installation.md | 2 +- environment-dev.yml | 2 +- monai/__init__.py | 2 +- pyproject.toml | 4 +-- requirements.txt | 2 +- setup.cfg | 5 ++- tests/testing_data/integration_answers.py | 2 +- 17 files changed, 25 insertions(+), 86 deletions(-) diff --git a/.github/workflows/cron.yml b/.github/workflows/cron.yml index d73b901ddb..e692c6eab3 100644 --- a/.github/workflows/cron.yml +++ b/.github/workflows/cron.yml @@ -13,16 +13,12 @@ jobs: strategy: matrix: environment: - - "PT182+CUDA102" - "PT191+CUDA113" - "PT110+CUDA113" - "PT112+CUDA113" - "PTLATEST+CUDA118" include: # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes - - environment: PT182+CUDA102 - pytorch: "torch==1.8.2 torchvision==0.9.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu102" - base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" - environment: PT191+CUDA113 pytorch: "torch==1.9.1 torchvision==0.10.1 --extra-index-url https://download.pytorch.org/whl/cu113" base: "nvcr.io/nvidia/pytorch:21.06-py3" # CUDA 11.3 @@ -44,46 +40,8 @@ jobs: - name: apt install run: | # FIXME: workaround for https://github.com/Project-MONAI/MONAI/issues/4200 - apt-key del 7fa2af80 && rm -rf /etc/apt/sources.list.d/nvidia-ml.list /etc/apt/sources.list.d/cuda.list apt-get update apt-get install -y wget - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb - dpkg -i cuda-keyring_1.0-1_all.deb - - if [ ${{ matrix.environment }} = "PT182+CUDA102" ] - then - PYVER=3.7 PYSFX=3 DISTUTILS=python3-distutils && \ - apt-get update && apt-get install -y --no-install-recommends \ - curl \ - pkg-config \ - python$PYVER \ - python$PYVER-dev \ - python$PYSFX-pip \ - $DISTUTILS \ - rsync \ - swig \ - unzip \ - zip \ - zlib1g-dev \ - libboost-locale-dev \ - libboost-program-options-dev \ - libboost-system-dev \ - libboost-thread-dev \ - libboost-test-dev \ - libgoogle-glog-dev \ - libjsoncpp-dev \ - cmake \ - git && \ - rm -rf /var/lib/apt/lists/* && \ - export PYTHONIOENCODING=utf-8 LC_ALL=C.UTF-8 && \ - rm -f /usr/bin/python && \ - rm -f /usr/bin/python`echo $PYVER | cut -c1-1` && \ - ln -s /usr/bin/python$PYVER /usr/bin/python && \ - ln -s /usr/bin/python$PYVER /usr/bin/python`echo $PYVER | cut -c1-1` && - curl -O https://bootstrap.pypa.io/get-pip.py && \ - python get-pip.py && \ - rm get-pip.py; - fi - name: Install the dependencies run: | which python @@ -164,7 +122,7 @@ jobs: if: github.repository == 'Project-MONAI/MONAI' strategy: matrix: - container: ["pytorch:21.02", "pytorch:21.10", "pytorch:22.12"] # 21.02, 21.10 for backward comp. + container: ["pytorch:22.09", "pytorch:22.11", "pytorch:22.12"] container: image: nvcr.io/nvidia/${{ matrix.container }}-py3 # testing with the latest pytorch base image options: "--gpus all" diff --git a/.github/workflows/pythonapp-gpu.yml b/.github/workflows/pythonapp-gpu.yml index 47259be9aa..589631d2e4 100644 --- a/.github/workflows/pythonapp-gpu.yml +++ b/.github/workflows/pythonapp-gpu.yml @@ -21,17 +21,12 @@ jobs: strategy: matrix: environment: - - "PT18+CUDA102" - "PT19+CUDA114DOCKER" - "PT110+CUDA111" - "PT112+CUDA118DOCKER" - "PT113+CUDA116" include: # https://docs.nvidia.com/deeplearning/frameworks/pytorch-release-notes - - environment: PT18+CUDA102 - # pytorch 1.8.2 LTS - pytorch: "torch==1.8.2 torchvision==0.9.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cu102" - base: "nvcr.io/nvidia/cuda:10.2-devel-ubuntu18.04" - environment: PT19+CUDA114DOCKER # 21.10: 1.10.0a0+0aef44c pytorch: "-h" # we explicitly set pytorch to -h to avoid pip install error @@ -55,18 +50,13 @@ jobs: - name: apt install if: github.event.pull_request.merged != true run: | - # FIXME: workaround for https://github.com/Project-MONAI/MONAI/issues/4200 - apt-key del 7fa2af80 && rm -rf /etc/apt/sources.list.d/nvidia-ml.list /etc/apt/sources.list.d/cuda.list apt-get update apt-get install -y wget - wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-keyring_1.0-1_all.deb - dpkg -i cuda-keyring_1.0-1_all.deb - if [ ${{ matrix.environment }} = "PT18+CUDA102" ] || \ - [ ${{ matrix.environment }} = "PT110+CUDA111" ] || \ + if [ ${{ matrix.environment }} = "PT110+CUDA111" ] || \ [ ${{ matrix.environment }} = "PT113+CUDA116" ] then - PYVER=3.7 PYSFX=3 DISTUTILS=python3-distutils && \ + PYVER=3.8 PYSFX=3 DISTUTILS=python3-distutils && \ apt-get update && apt-get install -y --no-install-recommends \ curl \ pkg-config \ @@ -134,7 +124,7 @@ jobs: # build for the current self-hosted CI Tesla V100 BUILD_MONAI=1 TORCH_CUDA_ARCH_LIST="7.0" ./runtests.sh --build --disttests ./runtests.sh --quick --unittests - if [ ${{ matrix.environment }} = "PT18+CUDA102" ]; then + if [ ${{ matrix.environment }} = "PT113+CUDA116" ]; then # test the clang-format tool downloading once coverage run -m tests.clang_format_utils fi diff --git a/.github/workflows/pythonapp-min.yml b/.github/workflows/pythonapp-min.yml index a5e24639bf..e4fd60d5f2 100644 --- a/.github/workflows/pythonapp-min.yml +++ b/.github/workflows/pythonapp-min.yml @@ -75,7 +75,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11'] timeout-minutes: 40 steps: - uses: actions/checkout@v3 @@ -120,7 +120,7 @@ jobs: strategy: fail-fast: false matrix: - pytorch-version: ['1.8.2', '1.9.1', '1.10.2', '1.11.0', '1.12.1', 'latest'] + pytorch-version: ['1.9.1', '1.10.2', '1.11.0', '1.12.1', '1.13', 'latest'] timeout-minutes: 40 steps: - uses: actions/checkout@v3 @@ -149,16 +149,8 @@ jobs: # min. requirements if [ ${{ matrix.pytorch-version }} == "latest" ]; then python -m pip install torch - elif [ ${{ matrix.pytorch-version }} == "1.8.2" ]; then - python -m pip install torch==1.8.2 --extra-index-url https://download.pytorch.org/whl/lts/1.8/cpu - elif [ ${{ matrix.pytorch-version }} == "1.9.1" ]; then - python -m pip install torch==1.9.1 - elif [ ${{ matrix.pytorch-version }} == "1.10.2" ]; then - python -m pip install torch==1.10.2 - elif [ ${{ matrix.pytorch-version }} == "1.11.0" ]; then - python -m pip install torch==1.11.0 - elif [ ${{ matrix.pytorch-version }} == "1.12.1" ]; then - python -m pip install torch==1.12.1 + else + python -m pip install torch==${{ matrix.pytorch-version }} fi python -m pip install -r requirements-min.txt python -m pip list diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 9a0b8142e3..e0e5341727 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -149,7 +149,7 @@ jobs: # install the latest pytorch for testing # however, "pip install monai*.tar.gz" will build cpp/cuda with an isolated # fresh torch installation according to pyproject.toml - python -m pip install torch>=1.8 torchvision + python -m pip install torch>=1.9 torchvision - name: Check packages run: | pip uninstall monai diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 22002ade17..9b473636fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] + python-version: ['3.9', '3.10', '3.11'] steps: - uses: actions/checkout@v3 with: @@ -82,7 +82,7 @@ jobs: uses: pypa/gh-action-pypi-publish@release/v1 with: password: ${{ secrets.TEST_PYPI }} - repository_url: https://test.pypi.org/legacy/ + repository-url: https://test.pypi.org/legacy/ versioning: # compute versioning file from python setup.py diff --git a/.github/workflows/setupapp.yml b/.github/workflows/setupapp.yml index b8efda471e..2504d5abc8 100644 --- a/.github/workflows/setupapp.yml +++ b/.github/workflows/setupapp.yml @@ -76,7 +76,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] + python-version: ['3.9', '3.10'] steps: - uses: actions/checkout@v3 with: diff --git a/.readthedocs.yml b/.readthedocs.yml index 9a68f0626e..fd21323127 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -18,7 +18,7 @@ sphinx: # Optionally set the version of Python and requirements required to build your docs python: - version: 3.7 + version: 3.8 install: - requirements: docs/requirements.txt # system_packages: true diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 07290936c5..d97cabc2cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -117,7 +117,7 @@ or (for new features that would not break existing functionality): ``` It is recommended that the new test `test_[module_name].py` is constructed by using only -python 3.7+ build-in functions, `torch`, `numpy`, `coverage` (for reporting code coverages) and `parameterized` (for organising test cases) packages. +python 3.8+ build-in functions, `torch`, `numpy`, `coverage` (for reporting code coverages) and `parameterized` (for organising test cases) packages. If it requires any other external packages, please make sure: - the packages are listed in [`requirements-dev.txt`](requirements-dev.txt) - the new test `test_[module_name].py` is added to the `exclude_cases` in [`./tests/min_tests.py`](./tests/min_tests.py) so that diff --git a/docs/images/python.svg b/docs/images/python.svg index 2d24bd007f..b7aa7c59bd 100644 --- a/docs/images/python.svg +++ b/docs/images/python.svg @@ -1 +1 @@ -pythonpython3.7+3.7+ +pythonpython3.8+3.8+ diff --git a/docs/requirements.txt b/docs/requirements.txt index a89961826f..1a284d22e1 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,5 @@ -f https://download.pytorch.org/whl/cpu/torch-1.12.1%2Bcpu-cp37-cp37m-linux_x86_64.whl -torch>=1.8 +torch>=1.9 pytorch-ignite==0.4.11 numpy>=1.20 itk>=5.2 diff --git a/docs/source/installation.md b/docs/source/installation.md index ffa9cdf091..ebbcc8d0a6 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -19,7 +19,7 @@ --- -MONAI's core functionality is written in Python 3 (>= 3.7) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). +MONAI's core functionality is written in Python 3 (>= 3.8) and only requires [Numpy](https://numpy.org/) and [Pytorch](https://pytorch.org/). The package is currently distributed via Github as the primary source code repository, and the Python package index (PyPI). The pre-built Docker images are made available on DockerHub. diff --git a/environment-dev.yml b/environment-dev.yml index 400822aaf3..d23958baba 100644 --- a/environment-dev.yml +++ b/environment-dev.yml @@ -6,7 +6,7 @@ channels: - conda-forge dependencies: - numpy>=1.20 - - pytorch>=1.8 + - pytorch>=1.9 - torchvision - pytorch-cuda=11.6 - pip diff --git a/monai/__init__.py b/monai/__init__.py index 1ee909cd24..9f542dd25c 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -17,7 +17,7 @@ from ._version import get_versions PY_REQUIRED_MAJOR = 3 -PY_REQUIRED_MINOR = 7 +PY_REQUIRED_MINOR = 8 version_dict = get_versions() __version__: str = version_dict.get("version", "0+unknown") diff --git a/pyproject.toml b/pyproject.toml index d71613fb43..eab98be1fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,13 +2,13 @@ requires = [ "wheel", "setuptools", - "torch>=1.8", + "torch>=1.9", "ninja", ] [tool.black] line-length = 120 -target-version = ['py37', 'py38', 'py39', 'py310'] +target-version = ['py38', 'py39', 'py310'] include = '\.pyi?$' exclude = ''' ( diff --git a/requirements.txt b/requirements.txt index 5a704330de..1569646794 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -torch>=1.8 +torch>=1.9 numpy>=1.20 diff --git a/setup.cfg b/setup.cfg index 379a031b89..0c305ee5a4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -21,7 +21,6 @@ classifiers = Intended Audience :: Healthcare Industry Programming Language :: C++ Programming Language :: Python :: 3 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 @@ -34,7 +33,7 @@ classifiers = Typing :: Typed [options] -python_requires = >= 3.7 +python_requires = >= 3.8 # for compiling and develop setup only # no need to specify the versions so that we could # compile for multiple targeted versions. @@ -42,7 +41,7 @@ setup_requires = torch ninja install_requires = - torch>=1.8 + torch>=1.9 numpy>=1.20 [options.extras_require] diff --git a/tests/testing_data/integration_answers.py b/tests/testing_data/integration_answers.py index 559cbe8a39..a4c58b06a1 100644 --- a/tests/testing_data/integration_answers.py +++ b/tests/testing_data/integration_answers.py @@ -221,7 +221,7 @@ ], }, }, - { # test answers for PyTorch 1.8 + { # test answers for cuda 10.x "integration_classification_2d": { "losses": [0.777176220515731, 0.16019743723664315, 0.07480076164197011, 0.045643698364780966], "best_metric": 0.9999418774120775,