2022-09-01 22:13:12 +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:
|
|
|
|
tags:
|
|
|
|
include:
|
|
|
|
- '*'
|
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- "master"
|
|
|
|
- "release/*"
|
|
|
|
- "refs/tags/*"
|
|
|
|
|
|
|
|
pr:
|
2022-09-05 17:11:12 +00:00
|
|
|
branches:
|
|
|
|
include:
|
|
|
|
- "master"
|
|
|
|
- "release/*"
|
|
|
|
paths:
|
|
|
|
include:
|
2022-11-11 16:38:09 +00:00
|
|
|
- ".azure/gpu-tests-lite.yml"
|
2022-11-10 09:16:46 +00:00
|
|
|
- "examples/lite/**"
|
|
|
|
- "examples/run_lite_examples.sh"
|
2022-11-11 16:38:09 +00:00
|
|
|
- "tests/tests_lite/run_standalone_*.sh"
|
|
|
|
- "tests/tests_pytorch/run_standalone_tests.sh" # used by Lite through a symlink
|
2022-09-05 17:11:12 +00:00
|
|
|
- "requirements/lite/**"
|
|
|
|
- "src/lightning_lite/**"
|
|
|
|
- "tests/tests_lite/**"
|
2022-11-11 16:38:09 +00:00
|
|
|
- "setup.cfg" # includes pytest config
|
2022-10-20 18:23:47 +00:00
|
|
|
- ".actions/**"
|
2022-09-01 22:13:12 +00:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
- job: testing
|
|
|
|
# how long to run the job before automatically cancelling
|
|
|
|
timeoutInMinutes: "20"
|
|
|
|
# how much time to give 'run always even if cancelled tasks' before stopping them
|
|
|
|
cancelTimeoutInMinutes: "2"
|
2022-10-05 10:43:54 +00:00
|
|
|
pool: lit-rtx-3090
|
|
|
|
variables:
|
|
|
|
DEVICES: $( python -c 'print("$(Agent.Name)".split("_")[-1])' )
|
2022-09-01 22:13:12 +00:00
|
|
|
container:
|
|
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.12-cuda11.6.1"
|
|
|
|
# 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"
|
2022-10-24 16:54:06 +00:00
|
|
|
# TODO: package parametrization
|
2022-09-01 22:13:12 +00:00
|
|
|
workspace:
|
|
|
|
clean: all
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- bash: |
|
|
|
|
lspci | egrep 'VGA|3D'
|
|
|
|
whereis nvidia
|
|
|
|
nvidia-smi
|
|
|
|
which python && which pip
|
|
|
|
python --version
|
|
|
|
pip --version
|
|
|
|
pip list
|
|
|
|
displayName: 'Image info & NVIDIA'
|
|
|
|
|
2022-10-05 10:43:54 +00:00
|
|
|
- bash: |
|
|
|
|
echo "##vso[task.setvariable variable=CUDA_VISIBLE_DEVICES]$(DEVICES)"
|
|
|
|
displayName: 'set visible devices'
|
|
|
|
|
2022-09-01 22:13:12 +00:00
|
|
|
- bash: |
|
|
|
|
set -e
|
2022-09-29 14:01:59 +00:00
|
|
|
CUDA_VERSION_MM=$(python -c "import torch ; print(''.join(map(str, torch.version.cuda.split('.')[:2])))")
|
2022-11-10 09:16:46 +00:00
|
|
|
pip install -e .[dev,strategies,examples] --find-links https://download.pytorch.org/whl/cu${CUDA_VERSION_MM}/torch_stable.html
|
2022-09-01 22:13:12 +00:00
|
|
|
pip list
|
|
|
|
env:
|
2022-10-31 13:10:08 +00:00
|
|
|
PACKAGE_NAME: "lite"
|
|
|
|
FREEZE_REQUIREMENTS: "1"
|
|
|
|
displayName: 'Install package & dependencies'
|
2022-09-01 22:13:12 +00:00
|
|
|
|
|
|
|
- bash: |
|
|
|
|
set -e
|
2022-10-05 10:43:54 +00:00
|
|
|
echo $CUDA_VISIBLE_DEVICES
|
2022-09-01 22:13:12 +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-09-01 22:13:12 +00:00
|
|
|
displayName: 'Env details'
|
|
|
|
|
|
|
|
- bash: python -m coverage run --source lightning_lite -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
|
|
|
|
env:
|
|
|
|
PL_RUN_CUDA_TESTS: "1"
|
|
|
|
workingDirectory: tests/tests_lite
|
|
|
|
displayName: 'Testing: Lite standard'
|
|
|
|
timeoutInMinutes: "10"
|
|
|
|
|
|
|
|
- bash: bash run_standalone_tests.sh
|
|
|
|
workingDirectory: tests/tests_lite
|
|
|
|
env:
|
|
|
|
PL_RUN_CUDA_TESTS: "1"
|
|
|
|
PL_STANDALONE_TESTS_SOURCE: "lightning_lite"
|
|
|
|
displayName: 'Testing: Lite standalone tests'
|
|
|
|
timeoutInMinutes: "10"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
python -m coverage report
|
|
|
|
python -m coverage xml
|
|
|
|
python -m coverage html
|
|
|
|
python -m codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) --flags=gpu,pytest --name="GPU-coverage" --env=linux,azure
|
|
|
|
ls -l
|
|
|
|
workingDirectory: tests/tests_lite
|
|
|
|
displayName: 'Statistics'
|
|
|
|
|
|
|
|
- task: PublishTestResults@2
|
|
|
|
displayName: 'Publish test results'
|
|
|
|
inputs:
|
|
|
|
testResultsFiles: '$(Build.StagingDirectory)/test-results.xml'
|
|
|
|
testRunTitle: '$(Agent.OS) - $(Build.DefinitionName) - Python $(python.version)'
|
|
|
|
condition: succeededOrFailed()
|
2022-11-10 09:16:46 +00:00
|
|
|
|
|
|
|
- script: |
|
|
|
|
# In order to run the examples, we need to substitute the meta package imports with the standalone package
|
|
|
|
python ../.actions/assistant.py copy_replace_imports --source_dir="./lite" --source_import="lightning.lite" --target_import="lightning_lite.lite"
|
|
|
|
set -e
|
|
|
|
bash run_lite_examples.sh --accelerator=cuda --devices=1
|
|
|
|
bash run_lite_examples.sh --accelerator=cuda --devices=2 --strategy ddp
|
|
|
|
workingDirectory: examples
|
|
|
|
displayName: 'Testing: Lite examples'
|