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:
|
2023-09-25 12:34:41 +00:00
|
|
|
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:
|
2023-06-15 15:25:59 +00:00
|
|
|
- ".actions/*"
|
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"
|
2023-03-07 16:24:46 +00:00
|
|
|
- "examples/pytorch/basics/backbone_image_classifier.py"
|
|
|
|
- "examples/pytorch/basics/autoencoder.py"
|
2022-09-21 14:28:35 +00:00
|
|
|
- "requirements/pytorch/**"
|
2023-03-06 17:19:50 +00:00
|
|
|
- "src/lightning/__init__.py"
|
|
|
|
- "src/lightning/__setup__.py"
|
|
|
|
- "src/lightning/__version__.py"
|
2023-02-01 18:22:42 +00:00
|
|
|
- "src/lightning/pytorch/**"
|
|
|
|
- "src/pytorch_lightning/*"
|
2022-09-21 14:28:35 +00:00
|
|
|
- "tests/tests_pytorch/**"
|
2024-06-05 16:32:56 +00:00
|
|
|
- "tests/run_standalone_*.sh"
|
2023-09-25 12:34:41 +00:00
|
|
|
- "pyproject.toml" # includes pytest config
|
2023-01-04 15:57:18 +00:00
|
|
|
- "requirements/fabric/**"
|
2023-02-01 17:18:32 +00:00
|
|
|
- "src/lightning/fabric/**"
|
|
|
|
- "src/lightning_fabric/*"
|
2022-11-22 01:25:01 +00:00
|
|
|
exclude:
|
2022-11-22 19:04:29 +00:00
|
|
|
- "requirements/*/docs.txt"
|
2022-11-22 01:25:01 +00:00
|
|
|
- "*.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
|
2023-02-09 13:39:03 +00:00
|
|
|
# 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"
|
2022-05-14 01:59:03 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-09-25 12:34:41 +00:00
|
|
|
"PyTorch | latest":
|
2024-04-29 11:16:13 +00:00
|
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.11-torch2.3-cuda12.1.0"
|
2024-01-26 15:42:09 +00:00
|
|
|
PACKAGE_NAME: "pytorch"
|
2023-09-25 12:34:41 +00:00
|
|
|
"Lightning | latest":
|
2024-11-12 14:59:08 +00:00
|
|
|
image: "pytorchlightning/pytorch_lightning:base-cuda-py3.12-torch2.5-cuda12.1.0"
|
2024-07-11 10:52:56 +00:00
|
|
|
PACKAGE_NAME: "lightning"
|
2022-10-05 10:43:54 +00:00
|
|
|
pool: lit-rtx-3090
|
|
|
|
variables:
|
|
|
|
DEVICES: $( python -c 'print("$(Agent.Name)".split("_")[-1])' )
|
2023-02-09 13:39:03 +00:00
|
|
|
FREEZE_REQUIREMENTS: "1"
|
2023-03-02 22:17:29 +00:00
|
|
|
PIP_CACHE_DIR: "/var/tmp/pip"
|
2023-12-13 19:27:49 +00:00
|
|
|
PL_RUN_CUDA_TESTS: "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'
|
2023-03-02 22:17:29 +00:00
|
|
|
options: "--gpus=all --shm-size=2gb -v /var/tmp:/var/tmp"
|
2021-02-10 20:21:20 +00:00
|
|
|
workspace:
|
|
|
|
clean: all
|
|
|
|
steps:
|
2023-09-25 12:34:41 +00:00
|
|
|
- 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"
|
|
|
|
scope=$(python -c 'n = "$(PACKAGE_NAME)" ; print(dict(pytorch="pytorch_lightning").get(n, n))')
|
|
|
|
echo "##vso[task.setvariable variable=COVERAGE_SOURCE]$scope"
|
2024-07-11 10:52:56 +00:00
|
|
|
python_ver=$(python -c "import sys; print(f'{sys.version_info.major}{sys.version_info.minor}')")
|
|
|
|
echo "##vso[task.setvariable variable=PYTHON_VERSION_MM]$python_ver"
|
2023-09-25 12:34:41 +00:00
|
|
|
displayName: "set env. vars"
|
2024-01-26 15:42:09 +00:00
|
|
|
- bash: |
|
2024-07-11 10:52:56 +00:00
|
|
|
echo "##vso[task.setvariable variable=TORCH_URL]https://download.pytorch.org/whl/test/cu${CUDA_VERSION_MM}"
|
|
|
|
echo "##vso[task.setvariable variable=TORCHVISION_URL]https://download.pytorch.org/whl/test/cu124/torchvision-0.19.0%2Bcu124-cp${PYTHON_VERSION_MM}-cp${PYTHON_VERSION_MM}-linux_x86_64.whl"
|
2024-01-26 15:42:09 +00:00
|
|
|
condition: endsWith(variables['Agent.JobName'], 'future')
|
|
|
|
displayName: "set env. vars 4 future"
|
2023-09-25 12:34:41 +00:00
|
|
|
|
|
|
|
- bash: |
|
|
|
|
echo $(DEVICES)
|
|
|
|
echo $CUDA_VISIBLE_DEVICES
|
|
|
|
echo $CUDA_VERSION_MM
|
|
|
|
echo $TORCH_URL
|
|
|
|
echo $COVERAGE_SOURCE
|
|
|
|
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])")
|
|
|
|
pip install -q wget packaging
|
|
|
|
python -m wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/adjust-torch-versions.py
|
|
|
|
for fpath in `ls requirements/**/*.txt`; do \
|
|
|
|
python ./adjust-torch-versions.py $fpath ${PYTORCH_VERSION}; \
|
|
|
|
done
|
|
|
|
displayName: "Adjust dependencies"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
extra=$(python -c "print({'lightning': 'pytorch-'}.get('$(PACKAGE_NAME)', ''))")
|
2024-07-11 10:52:56 +00:00
|
|
|
pip install -e ".[${extra}dev]" pytest-timeout -U --find-links="${TORCH_URL}" --find-links="${TORCHVISION_URL}"
|
2023-09-25 12:34:41 +00:00
|
|
|
displayName: "Install package & dependencies"
|
|
|
|
|
|
|
|
- bash: pip uninstall -y lightning
|
|
|
|
# without succeeded this could run even if the job has already failed
|
|
|
|
condition: and(succeeded(), eq(variables['PACKAGE_NAME'], 'pytorch'))
|
|
|
|
# Lightning is dependency of Habana or other accelerators/integrations so in case we test PL we need to remove it
|
|
|
|
displayName: "Drop LAI from extensions"
|
|
|
|
- bash: pip uninstall -y pytorch-lightning
|
|
|
|
# without succeeded this could run even if the job has already failed
|
|
|
|
condition: and(succeeded(), eq(variables['PACKAGE_NAME'], 'lightning'))
|
|
|
|
displayName: "Drop PL for LAI"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
set -e
|
|
|
|
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
|
2024-01-11 07:50:43 +00:00
|
|
|
python -c "import bitsandbytes"
|
2023-09-25 12:34:41 +00:00
|
|
|
displayName: "Env details"
|
|
|
|
|
|
|
|
- bash: python -m pytest pytorch_lightning
|
|
|
|
workingDirectory: src
|
|
|
|
# without succeeded this could run even if the job has already failed
|
|
|
|
condition: and(succeeded(), eq(variables['PACKAGE_NAME'], 'pytorch'))
|
|
|
|
displayName: "Testing: PyTorch doctests"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
python .actions/assistant.py copy_replace_imports --source_dir="./tests/tests_pytorch" \
|
|
|
|
--source_import="lightning.fabric,lightning.pytorch" \
|
|
|
|
--target_import="lightning_fabric,pytorch_lightning"
|
|
|
|
python .actions/assistant.py copy_replace_imports --source_dir="./examples/pytorch/basics" \
|
|
|
|
--source_import="lightning.fabric,lightning.pytorch" \
|
|
|
|
--target_import="lightning_fabric,pytorch_lightning"
|
|
|
|
# without succeeded this could run even if the job has already failed
|
|
|
|
condition: and(succeeded(), eq(variables['PACKAGE_NAME'], 'pytorch'))
|
|
|
|
displayName: "Adjust tests & examples"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
bash .actions/pull_legacy_checkpoints.sh
|
|
|
|
cd tests/legacy
|
|
|
|
bash generate_checkpoints.sh
|
|
|
|
ls -l checkpoints/
|
|
|
|
displayName: "Get legacy checkpoints"
|
|
|
|
|
2024-11-19 08:50:26 +00:00
|
|
|
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest tests_pytorch/ -v --durations=50
|
|
|
|
workingDirectory: tests/
|
2023-09-25 12:34:41 +00:00
|
|
|
displayName: "Testing: PyTorch standard"
|
|
|
|
timeoutInMinutes: "35"
|
|
|
|
|
2024-11-19 08:50:26 +00:00
|
|
|
- bash: bash ./run_standalone_tests.sh "tests_pytorch"
|
|
|
|
workingDirectory: tests/
|
2023-09-25 12:34:41 +00:00
|
|
|
env:
|
|
|
|
PL_USE_MOCKED_MNIST: "1"
|
|
|
|
PL_STANDALONE_TESTS_SOURCE: $(COVERAGE_SOURCE)
|
|
|
|
displayName: "Testing: PyTorch standalone tests"
|
|
|
|
timeoutInMinutes: "35"
|
|
|
|
|
|
|
|
- bash: bash run_standalone_tasks.sh
|
|
|
|
workingDirectory: tests/tests_pytorch
|
|
|
|
env:
|
|
|
|
PL_USE_MOCKED_MNIST: "1"
|
|
|
|
displayName: "Testing: PyTorch standalone tasks"
|
|
|
|
timeoutInMinutes: "10"
|
|
|
|
|
|
|
|
- bash: |
|
|
|
|
python -m coverage report
|
|
|
|
python -m coverage xml
|
|
|
|
python -m coverage html
|
|
|
|
|
|
|
|
# https://docs.codecov.com/docs/codecov-uploader
|
|
|
|
curl -Os https://uploader.codecov.io/latest/linux/codecov
|
|
|
|
chmod +x codecov
|
|
|
|
./codecov --token=$(CODECOV_TOKEN) --commit=$(Build.SourceVersion) \
|
|
|
|
--flags=gpu,pytest,${COVERAGE_SOURCE} --name="GPU-coverage" --env=linux,azure
|
|
|
|
ls -l
|
|
|
|
workingDirectory: tests/tests_pytorch
|
|
|
|
displayName: "Statistics"
|
|
|
|
|
|
|
|
- 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"
|