190 lines
6.9 KiB
YAML
190 lines
6.9 KiB
YAML
# 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:
|
|
branches:
|
|
include:
|
|
- "master"
|
|
- "release/*"
|
|
paths:
|
|
include:
|
|
- ".actions/**"
|
|
- ".azure/gpu-tests-pytorch.yml"
|
|
- "examples/run_pl_examples.sh"
|
|
- "examples/pl_basics/backbone_image_classifier.py"
|
|
- "examples/pl_basics/autoencoder.py"
|
|
- "examples/pl_fault_tolerant/automatic.py"
|
|
- "requirements/pytorch/**"
|
|
- "src/pytorch_lightning/**"
|
|
- "tests/tests_pytorch/**"
|
|
- "setup.cfg" # includes pytest config
|
|
- "requirements/fabric/**"
|
|
- "src/lightning_fabric/**"
|
|
exclude:
|
|
- "requirements/*/docs.txt"
|
|
- "*.md"
|
|
- "**/*.md"
|
|
|
|
jobs:
|
|
- job: testing
|
|
strategy:
|
|
matrix:
|
|
'PyTorch & strategies': # this uses torch 1.12 as not all strategies support 1.13 yet
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.12-cuda11.6.1"
|
|
scope: "strategies"
|
|
'PyTorch - latest':
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.9-torch1.13-cuda11.7.1"
|
|
scope: ""
|
|
# how long to run the job before automatically cancelling
|
|
timeoutInMinutes: "80"
|
|
# how much time to give 'run always even if cancelled tasks' before stopping them
|
|
cancelTimeoutInMinutes: "2"
|
|
pool: lit-rtx-3090
|
|
variables:
|
|
DEVICES: $( python -c 'print("$(Agent.Name)".split("_")[-1])' )
|
|
container:
|
|
image: $(image)
|
|
# default shm size is 64m. Increase it to avoid:
|
|
# 'Error while creating shared memory: unhandled system error, NCCL version 2.7.8'
|
|
options: "--gpus=all --shm-size=2gb"
|
|
workspace:
|
|
clean: all
|
|
|
|
steps:
|
|
|
|
- bash: |
|
|
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
|
|
lspci | egrep 'VGA|3D'
|
|
whereis nvidia
|
|
nvidia-smi
|
|
which python && which pip
|
|
python --version
|
|
pip --version
|
|
pip list
|
|
displayName: 'Image info & NVIDIA'
|
|
|
|
- bash: |
|
|
PYTORCH_VERSION=$(python -c "import torch; print(torch.__version__.split('+')[0])")
|
|
for fpath in `ls requirements/**/*.txt`; do \
|
|
python ./requirements/pytorch/adjust-versions.py $fpath ${PYTORCH_VERSION}; \
|
|
done
|
|
displayName: 'Adjust dependencies'
|
|
|
|
- bash: pip install -e .[extra,test,examples] --find-links ${TORCH_URL}
|
|
env:
|
|
PACKAGE_NAME: "pytorch"
|
|
FREEZE_REQUIREMENTS: "1"
|
|
displayName: 'Install package & extras'
|
|
|
|
- bash: pip uninstall -y -r requirements/pytorch/strategies.txt
|
|
condition: eq(variables['scope'], '')
|
|
displayName: 'UnInstall strategies'
|
|
|
|
- bash: |
|
|
set -e
|
|
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"
|
|
|
|
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
|
|
|
|
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'
|
|
|
|
- bash: |
|
|
set -e
|
|
pip list
|
|
python requirements/collect_env_details.py
|
|
python -c "import torch ; mgpu = torch.cuda.device_count() ; assert mgpu == 2, f'GPU: {mgpu}'"
|
|
python requirements/pytorch/check-avail-extras.py
|
|
displayName: 'Env details'
|
|
|
|
- bash: bash .actions/pull_legacy_checkpoints.sh
|
|
displayName: 'Get legacy checkpoints'
|
|
|
|
- bash: python -m pytest pytorch_lightning
|
|
workingDirectory: src
|
|
displayName: 'Testing: PyTorch doctests'
|
|
|
|
- bash: python -m coverage run --source pytorch_lightning -m pytest --ignore benchmarks -v --junitxml=$(Build.StagingDirectory)/test-results.xml --durations=50
|
|
env:
|
|
PL_RUN_CUDA_TESTS: "1"
|
|
workingDirectory: tests/tests_pytorch
|
|
displayName: 'Testing: PyTorch standard'
|
|
timeoutInMinutes: "35"
|
|
|
|
- bash: bash run_standalone_tests.sh
|
|
workingDirectory: tests/tests_pytorch
|
|
env:
|
|
PL_USE_MOCKED_MNIST: "1"
|
|
PL_RUN_CUDA_TESTS: "1"
|
|
PL_STANDALONE_TESTS_SOURCE: "pytorch_lightning"
|
|
displayName: 'Testing: PyTorch standalone tests'
|
|
timeoutInMinutes: "35"
|
|
|
|
- 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"
|
|
|
|
- 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_pytorch
|
|
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()
|
|
|
|
- script: |
|
|
set -e
|
|
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
|
|
env:
|
|
PL_USE_MOCKED_MNIST: "1"
|
|
displayName: 'Testing: PyTorch examples'
|
|
|
|
- bash: python -m pytest benchmarks -v --maxfail=2 --durations=0
|
|
workingDirectory: tests/tests_pytorch
|
|
env:
|
|
PL_RUN_CUDA_TESTS: "1"
|
|
displayName: 'Testing: PyTorch benchmarks'
|