2020-06-30 14:56:05 +00:00
|
|
|
name: PyTorch & Conda
|
|
|
|
|
|
|
|
# see: https://help.github.com/en/actions/reference/events-that-trigger-workflows
|
2020-09-10 22:38:29 +00:00
|
|
|
on: # Trigger the workflow on push or pull request, but only for the master branch
|
2020-06-30 14:56:05 +00:00
|
|
|
push:
|
2020-09-15 09:55:03 +00:00
|
|
|
branches: [master]
|
2020-06-30 14:56:05 +00:00
|
|
|
pull_request:
|
2020-09-15 09:55:03 +00:00
|
|
|
branches: [master]
|
2020-06-30 14:56:05 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
conda:
|
|
|
|
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
|
|
fail-fast: false
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-20.04]
|
|
|
|
python-version: [3.7]
|
2020-09-25 14:20:15 +00:00
|
|
|
pytorch-version: [1.3, 1.4, 1.5, 1.6, 1.7]
|
2020-06-30 14:56:05 +00:00
|
|
|
|
|
|
|
# Timeout: https://stackoverflow.com/a/59076067/4521646
|
2020-07-31 11:52:17 +00:00
|
|
|
timeout-minutes: 35
|
2020-06-30 14:56:05 +00:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
|
2020-09-17 18:30:39 +00:00
|
|
|
- name: Setup PyTorch nightly channel
|
|
|
|
if: matrix.pytorch-version >= 1.7
|
|
|
|
run: |
|
|
|
|
# NOTE: this requires that the channel is presented in the yaml before packages
|
|
|
|
python -c "fname = 'environment.yml' ; req = open(fname).read().replace('pytorch', 'pytorch-nightly', 1) ; open(fname, 'w').write(req)"
|
|
|
|
|
|
|
|
- name: Setup PyTorch version
|
2020-06-30 14:56:05 +00:00
|
|
|
run: |
|
|
|
|
python -c "fname = 'environment.yml' ; req = open(fname).read().replace('torch>=1.3', 'torch=${{ matrix.pytorch-version }}') ; open(fname, 'w').write(req)"
|
|
|
|
cat environment.yml
|
|
|
|
|
|
|
|
- name: Cache conda
|
2020-07-31 10:31:23 +00:00
|
|
|
uses: actions/cache@v2
|
2020-06-30 14:56:05 +00:00
|
|
|
with:
|
|
|
|
path: ~/conda_pkgs_dir
|
2020-07-31 10:31:23 +00:00
|
|
|
key: ${{ runner.os }}-conda-py${{ matrix.python-version }}-pt${{ matrix.pytorch-version }}-${{ hashFiles('environment.yml') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-conda-py${{ matrix.python-version }}-pt${{ matrix.pytorch-version }}-
|
|
|
|
|
|
|
|
# Add another cache for Pip as not all packages lives in Conda env
|
|
|
|
- name: Cache pip
|
|
|
|
uses: actions/cache@v2
|
|
|
|
with:
|
|
|
|
path: ~/.cache/pip
|
|
|
|
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-pt${{ matrix.pytorch-version }}-${{ hashFiles('requirements/base.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-pip-py${{ matrix.python-version }}-pt${{ matrix.pytorch-version }}-
|
2020-06-30 14:56:05 +00:00
|
|
|
|
|
|
|
# https://docs.conda.io/projects/conda/en/4.6.0/_downloads/52a95608c49671267e40c689e0bc00ca/conda-cheatsheet.pdf
|
|
|
|
# https://gist.github.com/mwouts/9842452d020c08faf9e84a3bba38a66f
|
|
|
|
- name: Setup Miniconda
|
|
|
|
uses: goanpeca/setup-miniconda@v1.6.0
|
2020-09-26 17:30:25 +00:00
|
|
|
env:
|
|
|
|
# MAKEFLAGS: "-j2"
|
|
|
|
HOROVOD_WITHOUT_MXNET: 1
|
|
|
|
HOROVOD_WITHOUT_TENSORFLOW: 1
|
2020-06-30 14:56:05 +00:00
|
|
|
with:
|
|
|
|
# auto-update-conda: true
|
|
|
|
auto-activate-base: false
|
2020-07-31 10:31:23 +00:00
|
|
|
# miniconda-version: 4.7.12 # This downloads a new conda, use the conda-version
|
|
|
|
conda-version: 4.7.12
|
2020-06-30 14:56:05 +00:00
|
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
environment-file: environment.yml
|
2020-09-10 22:38:29 +00:00
|
|
|
activate-environment: lightning
|
2020-06-30 14:56:05 +00:00
|
|
|
use-only-tar-bz2: true # IMPORTANT: This needs to be set for caching to work properly!
|
|
|
|
|
|
|
|
- name: Reinstall Horovod if necessary
|
2020-07-30 21:39:07 +00:00
|
|
|
if: runner.os != 'windows'
|
2020-09-26 17:30:25 +00:00
|
|
|
env:
|
|
|
|
HOROVOD_BUILD_ARCH_FLAGS: "-mfma"
|
2020-06-30 14:56:05 +00:00
|
|
|
run: |
|
2020-07-30 21:39:07 +00:00
|
|
|
HOROVOD_BUILT=$(python -c "import horovod.torch; horovod.torch.nccl_built(); print('SUCCESS')" || true)
|
2020-06-30 14:56:05 +00:00
|
|
|
if [[ $HOROVOD_BUILT != "SUCCESS" ]]; then
|
|
|
|
pip uninstall -y horovod
|
2020-09-26 17:30:25 +00:00
|
|
|
pip install --no-cache-dir $(grep "horovod" requirements/extra.txt)
|
2020-06-30 14:56:05 +00:00
|
|
|
fi
|
|
|
|
horovodrun --check-build
|
|
|
|
shell: bash -l {0}
|
|
|
|
|
|
|
|
- name: Cache datasets
|
2020-07-31 10:31:23 +00:00
|
|
|
uses: actions/cache@v2
|
2020-06-30 14:56:05 +00:00
|
|
|
with:
|
|
|
|
path: Datasets # This path is specific to Ubuntu
|
|
|
|
# Look to see if there is a cache hit for the corresponding requirements file
|
|
|
|
key: pl-dataset
|
|
|
|
|
|
|
|
- name: Tests
|
|
|
|
run: |
|
|
|
|
conda info
|
|
|
|
conda list
|
2020-09-10 22:38:29 +00:00
|
|
|
pip install --requirement requirements/test.txt
|
|
|
|
pip list
|
2020-06-30 14:56:05 +00:00
|
|
|
# NOTE: run coverage on tests does not propagare faler status for Win, https://github.com/nedbat/coveragepy/issues/1003
|
2020-09-10 22:38:29 +00:00
|
|
|
python -m pytest pytorch_lightning tests -v --durations=0 --junitxml=junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
|
2020-06-30 14:56:05 +00:00
|
|
|
# coverage report
|
|
|
|
shell: bash -l {0}
|
|
|
|
|
|
|
|
- name: Upload pytest test results
|
|
|
|
uses: actions/upload-artifact@master
|
|
|
|
with:
|
|
|
|
name: pytest-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}
|
|
|
|
path: junit/test-results-${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.requires }}.xml
|
|
|
|
# Use always() to always run this step to publish test results when there are test failures
|
|
|
|
if: always()
|