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-22 19:04:29 +00:00
|
|
|
- ".actions/**"
|
2023-01-04 15:57:18 +00:00
|
|
|
- ".azure/gpu-tests-fabric.yml"
|
|
|
|
- "examples/fabric/**"
|
|
|
|
- "examples/run_fabric_examples.sh"
|
|
|
|
- "tests/tests_fabric/run_standalone_*.sh"
|
2023-01-05 20:35:56 +00:00
|
|
|
- "tests/tests_pytorch/run_standalone_tests.sh" # used by fabric through a symlink
|
2023-01-04 15:57:18 +00:00
|
|
|
- "requirements/fabric/**"
|
2023-02-01 17:18:32 +00:00
|
|
|
- "src/lightning/fabric/**"
|
|
|
|
- "src/lightning_fabric/*"
|
2023-01-04 15:57:18 +00:00
|
|
|
- "tests/tests_fabric/**"
|
2023-01-19 16:48:28 +00:00
|
|
|
- "pyproject.toml" # includes pytest config
|
2022-11-22 01:25:01 +00:00
|
|
|
exclude:
|
2022-11-26 01:16:48 +00:00
|
|
|
- "requirements/*/docs.txt"
|
2022-11-22 01:25:01 +00:00
|
|
|
- "*.md"
|
|
|
|
- "**/*.md"
|
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:
|
2023-01-04 22:44:23 +00:00
|
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.13-cuda11.7.1"
|
2022-09-01 22:13:12 +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"
|
2022-10-24 16:54:06 +00:00
|
|
|
# TODO: package parametrization
|
2022-09-01 22:13:12 +00:00
|
|
|
workspace:
|
|
|
|
clean: all
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- bash: |
|
2022-11-12 14:58:37 +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=TORCH_URL]https://download.pytorch.org/whl/cu${cuda_ver}/torch_stable.html"
|
|
|
|
displayName: 'set env. vars'
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
echo $CUDA_VISIBLE_DEVICES
|
|
|
|
echo $TORCH_URL
|
2022-09-01 22:13:12 +00:00
|
|
|
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: |
|
2022-11-12 14:58:37 +00:00
|
|
|
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
|
2022-12-22 06:21:52 +00:00
|
|
|
for fpath in `ls requirements/**/*.txt`; do \
|
|
|
|
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
|
|
|
|
done
|
2022-11-12 14:58:37 +00:00
|
|
|
displayName: 'Adjust dependencies'
|
2022-10-05 10:43:54 +00:00
|
|
|
|
2022-09-01 22:13:12 +00:00
|
|
|
- bash: |
|
2022-11-12 14:58:37 +00:00
|
|
|
pip install -e .[dev,strategies,examples] --find-links ${TORCH_URL}
|
2022-09-01 22:13:12 +00:00
|
|
|
env:
|
2023-01-04 15:57:18 +00:00
|
|
|
PACKAGE_NAME: "fabric"
|
2022-10-31 13:10:08 +00:00
|
|
|
FREEZE_REQUIREMENTS: "1"
|
|
|
|
displayName: 'Install package & dependencies'
|
2022-09-01 22:13:12 +00:00
|
|
|
|
|
|
|
- bash: |
|
|
|
|
set -e
|
2022-11-12 14:58:37 +00:00
|
|
|
pip list
|
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'
|
|
|
|
|
2023-01-04 15:57:18 +00:00
|
|
|
- bash: python -m coverage run --source lightning_fabric -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
|
2022-09-01 22:13:12 +00:00
|
|
|
env:
|
|
|
|
PL_RUN_CUDA_TESTS: "1"
|
2023-01-04 15:57:18 +00:00
|
|
|
workingDirectory: tests/tests_fabric
|
2023-01-05 20:35:56 +00:00
|
|
|
displayName: 'Testing: fabric standard'
|
2022-09-01 22:13:12 +00:00
|
|
|
timeoutInMinutes: "10"
|
|
|
|
|
|
|
|
- bash: bash run_standalone_tests.sh
|
2023-01-04 15:57:18 +00:00
|
|
|
workingDirectory: tests/tests_fabric
|
2022-09-01 22:13:12 +00:00
|
|
|
env:
|
|
|
|
PL_RUN_CUDA_TESTS: "1"
|
2023-01-04 15:57:18 +00:00
|
|
|
PL_STANDALONE_TESTS_SOURCE: "lightning_fabric"
|
2023-01-05 20:35:56 +00:00
|
|
|
displayName: 'Testing: fabric standalone tests'
|
2022-09-01 22:13:12 +00:00
|
|
|
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
|
2023-01-04 15:57:18 +00:00
|
|
|
workingDirectory: tests/tests_fabric
|
2022-09-01 22:13:12 +00:00
|
|
|
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
|
2023-01-04 15:57:18 +00:00
|
|
|
python ../.actions/assistant.py copy_replace_imports --source_dir="./fabric" --source_import="lightning.fabric" --target_import="lightning_fabric.fabric"
|
2022-11-10 09:16:46 +00:00
|
|
|
set -e
|
2023-01-04 15:57:18 +00:00
|
|
|
bash run_fabric_examples.sh --accelerator=cuda --devices=1
|
|
|
|
bash run_fabric_examples.sh --accelerator=cuda --devices=2 --strategy ddp
|
2022-11-10 09:16:46 +00:00
|
|
|
workingDirectory: examples
|
2023-01-05 20:35:56 +00:00
|
|
|
displayName: 'Testing: fabric examples'
|