Skip to content

PyTorch version tests #1669

PyTorch version tests

PyTorch version tests #1669

name: PyTorch version tests
on:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#onschedule
schedule:
# Run at 00:00 UTC Every Day
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 85
strategy:
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.4.1, 2.3.1, 2.2.2, 2.0.1, 1.13.1, 1.12.1, 1.10.0, 1.8.1]
exclude:
# 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
python-version: 3.9
- pytorch-version: 1.8.1
python-version: "3.10"
- pytorch-version: 1.10.0
python-version: "3.10"
- pytorch-version: 1.11.0
python-version: "3.10"
steps:
- uses: actions/checkout@v4
- name: Get year & week number
id: get-date
run: echo "date=$(/bin/date "+%Y-%U")" >> $GITHUB_OUTPUT
shell: bash -l {0}
- name: Get pip cache dir
id: pip-cache
run: |
python3 -m pip install -U pip
echo "pip_cache=$(python3 -m pip cache dir)" >> $GITHUB_OUTPUT
shell: bash -l {0}
- uses: actions/cache@v3
with:
path: |
~/conda_pkgs_dir
${{ steps.pip-cache.outputs.pip_cache }}
key: ${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-version }}-${{ hashFiles('requirements-dev.txt') }}
restore-keys: |
${{ steps.get-date.outputs.date }}-pytorch-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pytorch-version }}-
- name: Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
- name: Install dependencies
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
# pytorch>=1.9.0,<1.11.0 is using "from setuptools import distutils; distutils.version.LooseVersion" anti-pattern
# which raises the error: AttributeError: module 'distutils' has no attribute 'version' for setuptools>59
bad_pth_version=$(python -c "import torch; print('.'.join(torch.__version__.split('.')[:2]) in ['1.9', '1.10'])")
if [ "${bad_pth_version}" == "True" ]; then
pip install --upgrade "setuptools<59"
python -c "from setuptools import distutils; distutils.version.LooseVersion"
fi
- name: Download MNIST
uses: pytorch-ignite/download-mnist-github-action@master
with:
target_dir: /tmp
- name: Run Tests
uses: nick-fields/retry@v3
with:
max_attempts: 5
timeout_minutes: 15
shell: bash
command: bash -l tests/run_cpu_tests.sh "not test_time_profilers"
new_command_on_retry: USE_LAST_FAILED=1 bash -l tests/run_cpu_tests.sh "not test_time_profilers"
create-issue:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#needs-context
needs: build
if: always() && needs.build.result == 'failure'
steps:
- uses: actions/checkout@v4
- uses: JasonEtco/create-an-issue@v2
name: Create issue if pytorch version tests failed
with:
filename: .github/failed_schedule_issue_template.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}