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/*"
2022-07-14 19:55:30 +00:00
2021-02-10 09:43:26 +00:00
pr :
2022-09-21 14:28:35 +00:00
branches :
include :
- "master"
- "release/*"
paths :
include :
2022-10-12 13:18:12 +00:00
- ".azure/gpu-tests-pytorch.yml"
2022-09-21 14:28:35 +00:00
- "examples/run_pl_examples.sh"
- "examples/pl_basics/backbone_image_classifier.py"
- "examples/pl_basics/autoencoder.py"
- "examples/pl_fault_tolerant/automatic.py"
- "examples/test_pl_examples.py"
- "examples/pl_integrations/dali_image_classifier.py"
- "requirements/pytorch/**"
- "src/pytorch_lightning/**"
- "tests/tests_pytorch/**"
- "setup.cfg" # includes pytest config
- "requirements/lite/**"
- "src/lightning_lite/**"
2022-10-20 18:23:47 +00:00
- ".actions/**"
2022-11-22 01:25:01 +00:00
exclude :
- "requirements/**/docs.txt"
- "*.md"
- "**/*.md"
2022-08-17 14:15:23 +00:00
2021-02-10 20:21:20 +00:00
jobs :
2022-06-15 22:10:49 +00:00
- job : testing
2022-05-14 01:59:03 +00:00
strategy :
matrix :
2022-11-12 14:58:37 +00:00
'PyTorch & strategies' : # this uses torch 1.12 as not all strategies support 1.13 yet
2022-08-23 16:10:52 +00:00
image : "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.12-cuda11.6.1"
2022-11-12 14:58:37 +00:00
scope : "strategies"
'PyTorch - latest' :
image : "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.13-cuda11.6.1"
scope : ""
2021-02-10 20:21:20 +00:00
# how long to run the job before automatically cancelling
2022-07-14 22:58:32 +00:00
timeoutInMinutes : "80"
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"
2022-10-05 10:43:54 +00:00
pool : lit-rtx-3090
variables :
DEVICES : $( python -c 'print("$(Agent.Name)".split("_")[-1])' )
2021-02-10 20:21:20 +00:00
container :
2022-05-14 01:59:03 +00:00
image : $(image)
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'
2022-10-05 10:43:54 +00:00
options : "--gpus=all --shm-size=2gb"
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 :
2022-10-31 19:50:51 +00:00
2021-02-10 20:21:20 +00:00
- bash : |
2022-10-31 19:50:51 +00:00
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
cuda_ver=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
echo "##vso[task.setvariable variable=CUDA_VERSION_MM]$cuda_ver"
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html"
displayName : 'set env. vars'
- bash : |
echo $CUDA_VISIBLE_DEVICES
echo $CUDA_VERSION_MM
echo $TORCH_URL
2021-02-10 20:21:20 +00:00
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
2022-10-05 10:43:54 +00:00
- bash : |
2022-06-21 15:11:33 +00:00
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'horovod' not in line] ; open(fname, 'w').writelines(lines)"
2022-07-28 14:07:57 +00:00
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'bagua' not in line] ; open(fname, 'w').writelines(lines)"
2022-10-11 11:59:09 +00:00
python -c "fname = 'requirements/pytorch/strategies.txt' ; lines = [line for line in open(fname).readlines() if 'colossalai' not in line] ; open(fname, 'w').writelines(lines)"
2022-09-29 14:01:59 +00:00
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
2022-08-25 17:30:06 +00:00
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/base.txt ${PYTORCH_VERSION}
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/extra.txt ${PYTORCH_VERSION}
python ./requirements/pytorch/adjust-versions.py requirements/pytorch/examples.txt ${PYTORCH_VERSION}
2022-10-31 19:50:51 +00:00
displayName : 'Adjust dependencies'
2022-09-29 14:01:59 +00:00
2022-11-12 14:58:37 +00:00
- bash : pip install -e .[dev,examples] --find-links ${TORCH_URL}
2022-10-31 19:50:51 +00:00
env :
PACKAGE_NAME : "pytorch"
FREEZE_REQUIREMENTS : "1"
2022-11-12 14:58:37 +00:00
displayName : 'Install package & extras'
2022-09-29 14:01:59 +00:00
2022-10-31 19:50:51 +00:00
- bash : |
set -e
2022-09-29 14:01:59 +00:00
CUDA_VERSION_BAGUA=$(python -c "print([ver for ver in [116,113,111,102] if $CUDA_VERSION_MM >= ver][0])")
pip install "bagua-cuda$CUDA_VERSION_BAGUA"
2022-10-11 11:59:09 +00:00
PYTORCH_VERSION_COLOSSALAI=$(python -c "import torch; print(torch.__version__.split('+')[0][:4])")
CUDA_VERSION_MM_COLOSSALAI=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda)))")
CUDA_VERSION_COLOSSALAI=$(python -c "print([ver for ver in [11.3, 11.1] if $CUDA_VERSION_MM_COLOSSALAI >= ver][0])")
pip install "colossalai==0.1.10+torch${PYTORCH_VERSION_COLOSSALAI}cu${CUDA_VERSION_COLOSSALAI}" --find-links https://release.colossalai.org
2022-11-12 14:58:37 +00:00
pip install -r requirements/pytorch/strategies.txt --find-links ${TORCH_URL}
python requirements/pytorch/check-avail-strategies.py
condition : eq(variables['scope'], 'strategies')
displayName : 'Install strategies'
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
2022-11-12 14:58:37 +00:00
pip list
2021-07-19 11:26:09 +00:00
python requirements/collect_env_details.py
2022-10-05 10:43:54 +00:00
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu == 2, f'GPU: {mgpu}'"
2022-06-21 15:11:33 +00:00
python requirements/pytorch/check-avail-extras.py
2021-02-10 20:21:20 +00:00
displayName : 'Env details'
2021-02-10 09:43:26 +00:00
2022-06-02 13:39:14 +00:00
- bash : bash .actions/pull_legacy_checkpoints.sh
2021-02-10 20:21:20 +00:00
displayName : 'Get legacy checkpoints'
2021-02-10 09:43:26 +00:00
2022-10-19 19:05:23 +00:00
- bash : python -m pytest pytorch_lightning
workingDirectory : src
2022-06-15 22:10:49 +00:00
displayName: 'Testing : PyTorch doctests'
2021-02-10 20:21:20 +00:00
2022-06-15 22:10:49 +00:00
- bash : python -m coverage run --source pytorch_lightning -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
2022-07-15 11:51:23 +00:00
env :
PL_RUN_CUDA_TESTS : "1"
2022-06-15 22:10:49 +00:00
workingDirectory : tests/tests_pytorch
2022-07-14 22:58:32 +00:00
displayName: 'Testing : PyTorch standard'
timeoutInMinutes : "35"
2022-06-15 00:54:55 +00:00
2022-06-15 22:10:49 +00:00
- bash : bash run_standalone_tests.sh
workingDirectory : tests/tests_pytorch
2021-07-19 07:41:18 +00:00
env :
PL_USE_MOCKED_MNIST : "1"
2022-07-15 11:51:23 +00:00
PL_RUN_CUDA_TESTS : "1"
2022-09-01 22:13:12 +00:00
PL_STANDALONE_TESTS_SOURCE : "pytorch_lightning"
2022-06-15 22:10:49 +00:00
displayName: 'Testing : PyTorch standalone tests'
2022-07-14 22:58:32 +00:00
timeoutInMinutes : "35"
2022-07-27 15:40:40 +00:00
2022-08-26 11:18:11 +00:00
- bash : bash run_standalone_tasks.sh
workingDirectory : tests/tests_pytorch
env :
PL_USE_MOCKED_MNIST : "1"
PL_RUN_CUDA_TESTS : "1"
displayName: 'Testing : PyTorch standalone tasks'
timeoutInMinutes : "10"
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
2022-06-15 22:10:49 +00:00
workingDirectory : tests/tests_pytorch
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)'
2022-09-21 14:28:35 +00:00
condition : succeededOrFailed()
2021-03-15 14:38:40 +00:00
2021-03-20 18:58:59 +00:00
- script : |
set -e
2022-06-15 12:53:51 +00:00
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=1
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp
bash run_pl_examples.sh --trainer.accelerator=gpu --trainer.devices=2 --trainer.strategy=ddp --trainer.precision=16
workingDirectory : examples
2021-03-22 16:49:01 +00:00
env :
PL_USE_MOCKED_MNIST : "1"
2022-06-15 22:10:49 +00:00
displayName: 'Testing : PyTorch examples'
2021-07-19 07:41:18 +00:00
2022-06-15 22:10:49 +00:00
- bash : python -m pytest benchmarks -v --maxfail=2 --durations=0
workingDirectory : tests/tests_pytorch
2022-07-15 11:51:23 +00:00
env :
PL_RUN_CUDA_TESTS : "1"
2022-06-15 22:10:49 +00:00
displayName: 'Testing : PyTorch benchmarks'