2021-02-10 09:43:26 +00:00
# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python
trigger :
2021-02-18 21:41:16 +00:00
tags :
include :
- '*'
2021-02-10 09:43:26 +00:00
branches :
include :
2021-07-28 16:09:15 +00:00
- "master"
- "release/*"
- "refs/tags/*"
2021-02-10 09:43:26 +00:00
pr :
2021-07-28 16:09:15 +00:00
- "master"
- "release/*"
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
jobs :
- job : pytest
# how long to run the job before automatically cancelling
2022-05-04 14:06:02 +00:00
timeoutInMinutes : "55"
2021-02-10 20:21:20 +00:00
# how much time to give 'run always even if cancelled tasks' before stopping them
2021-07-28 16:09:15 +00:00
cancelTimeoutInMinutes : "2"
2021-02-10 09:43:26 +00:00
2021-11-01 11:42:11 +00:00
pool : azure-gpus-spot
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
# ToDo: this need to have installed docker in the base image...
container :
# base ML image: mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.2-cudnn8-ubuntu18.04
2021-06-24 16:56:43 +00:00
# run on torch 1.8 as it's the LTS version
2022-05-06 02:56:57 +00:00
image : "pytorchlightning/pytorch_lightning:base-cuda-py3.7-torch1.8"
2021-06-24 16:56:43 +00:00
# default shm size is 64m. Increase it to avoid:
# 'Error while creating shared memory: unhandled system error, NCCL version 2.7.8'
2021-07-19 07:41:18 +00:00
options : "--runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=all --shm-size=512m"
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
workspace :
clean : all
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
steps :
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
- bash : |
lspci | egrep 'VGA|3D'
whereis nvidia
nvidia-smi
2022-02-16 20:15:44 +00:00
which python && which pip
2021-02-10 20:21:20 +00:00
python --version
pip --version
pip list
displayName : 'Image info & NVIDIA'
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
- bash : |
2022-05-04 14:06:02 +00:00
python -c "fname = 'requirements/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'horovod' not in line] ; open(fname, 'w').writelines(lines)"
2022-04-11 15:29:54 +00:00
CUDA_VERSION_MM=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
pip install "bagua-cuda$CUDA_VERSION_MM>=0.9.0"
2021-05-21 11:35:12 +00:00
pip install . --requirement requirements/devel.txt
2022-05-06 02:56:57 +00:00
# TODO: Prepare a docker image with 1.8.2 (LTS) installed and remove manual installation.
pip install torch==1.8.2+cu102 torchvision==0.9.2+cu102 torchtext==0.9.2 -f https://download.pytorch.org/whl/lts/1.8/torch_lts.html
2021-02-10 20:21:20 +00:00
pip list
displayName : 'Install dependencies'
2021-02-10 09:43:26 +00:00
2021-02-19 21:45:53 +00:00
- bash : |
2022-03-11 09:20:47 +00:00
set -e
2021-07-19 11:26:09 +00:00
python requirements/collect_env_details.py
2021-02-19 21:45:53 +00:00
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu >= 2, f'GPU: {mgpu}'"
2022-03-11 09:20:47 +00:00
python requirements/check-avail-strategies.py
python requirements/check-avail-extras.py
2021-02-10 20:21:20 +00:00
displayName : 'Env details'
2021-02-10 09:43:26 +00:00
2021-02-10 20:21:20 +00:00
- bash : |
wget https://pl-public-data.s3.amazonaws.com/legacy/checkpoints.zip -P legacy/
unzip -o legacy/checkpoints.zip -d legacy/
ls -l legacy/checkpoints/
displayName : 'Get legacy checkpoints'
2021-02-10 09:43:26 +00:00
2021-02-19 21:45:53 +00:00
- bash : |
2021-11-19 02:07:33 +00:00
python -m coverage run --source pytorch_lightning -m pytest pytorch_lightning tests --ignore tests/benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
2021-02-10 20:21:20 +00:00
displayName: 'Testing : standard'
2021-02-17 20:23:42 +00:00
- bash : |
2021-11-26 17:13:14 +00:00
bash tests/standalone_tests.sh
2021-07-19 07:41:18 +00:00
env :
PL_USE_MOCKED_MNIST : "1"
2021-11-26 17:13:14 +00:00
displayName: 'Testing : standalone'
2021-02-10 20:21:20 +00:00
- bash : |
python -m coverage report
python -m coverage xml
2021-03-15 14:38:40 +00:00
python -m coverage html
python -m codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) --flags=gpu,pytest --name="GPU-coverage" --env=linux,azure
ls -l
2021-02-10 20:21:20 +00:00
displayName : 'Statistics'
2021-03-15 14:38:40 +00:00
- task : PublishTestResults@2
displayName : 'Publish test results'
inputs :
testResultsFiles : '$(Build.StagingDirectory)/test-results.xml'
testRunTitle : '$(Agent.OS) - $(Build.DefinitionName) - Python $(python.version)'
condition : succeededOrFailed()
2021-07-28 16:09:15 +00:00
# todo: re-enable after schema check pass, also atm it seems does not have any effect
#- task: PublishCodeCoverageResults@2
# displayName: 'Publish coverage report'
# inputs:
# codeCoverageTool: 'Cobertura'
# summaryFileLocation: 'coverage.xml'
# reportDirectory: '$(Build.SourcesDirectory)/htmlcov'
# testRunTitle: '$(Agent.OS) - $(Build.BuildNumber)[$(Agent.JobName)] - Python $(python.version)'
# condition: succeededOrFailed()
2021-03-15 14:38:40 +00:00
2021-03-20 18:58:59 +00:00
- script : |
set -e
2021-03-05 16:50:21 +00:00
python -m pytest pl_examples -v --maxfail=2 --durations=0
2022-03-23 19:52:12 +00:00
bash pl_examples/run_examples.sh --trainer.accelerator=gpu --trainer.devices=1
bash pl_examples/run_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp
bash pl_examples/run_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp --trainer.precision=16
2021-03-22 16:49:01 +00:00
env :
PL_USE_MOCKED_MNIST : "1"
2021-07-06 12:14:04 +00:00
displayName: 'Testing : examples'
2021-07-19 07:41:18 +00:00
- bash : |
2021-11-19 02:07:33 +00:00
python -m pytest tests/benchmarks -v --maxfail=2 --durations=0
2021-07-19 07:41:18 +00:00
displayName: 'Testing : benchmarks'