Unverified Commit 9851a69f authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

migrate prototype CI to Nova (#7037)

* improve prototype GPU CI config

* consolidate CPU and GPU prototype workflows

* [REVERTME] deactivate other CI

* syntax

* fix name

* fix echo mutex

* style

* fix runner

* add jobname

* run all prototype tests

* fix mutex echo

* cleanup

* Revert "[REVERTME] deactivate other CI"

This reverts commit c931ff2c27bbc2b04324b777ae39a6fc25e50b8a.

* remove old workflows

* use free GHA runner for CPU tests

* Revert "use free GHA runner for CPU tests"

This reverts commit a209b31387d9d14bc6446743587db244bccc2106.

* [REVERTME] turn warnings into errors

* try fix test warnings

* fix module import in tests

* revert

* int -> float

* [REVERTME] why do we have to mark as safe?
parent 657c0767
name: Prototype tests on Linux
on:
pull_request:
jobs:
tests:
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
gpu-arch-type: ["cpu"]
gpu-arch-version: [""]
runner: ["linux.2xlarge"]
include:
- python-version: "3.8"
gpu-arch-type: cuda
gpu-arch-version: "11.6"
runner: linux.4xlarge.nvidia.gpu
fail-fast: false
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
job-name: Python ${{ matrix.python-version }}, ${{ matrix.gpu-arch-type }}
repository: pytorch/vision
gpu-arch-type: ${{ matrix.gpu-arch-type }}
gpu-arch-version: ${{ matrix.gpu-arch-version }}
runner: ${{ matrix.runner }}
timeout: 45
script: |
# Mark Build Directory Safe
echo '::group::Set PyTorch conda channel'
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
POSTFIX=test
else
POSTFIX=nightly
fi
PYTORCH_CHANNEL=pytorch-"${POSTFIX}"
echo "${PYTORCH_CHANNEL}"
echo '::endgroup::'
echo '::group::Set PyTorch conda mutex'
if [[ ${{ matrix.gpu-arch-type }} = 'cuda' ]]; then
PYTORCH_MUTEX="pytorch-cuda=${{ matrix.gpu-arch-version }}"
else
PYTORCH_MUTEX=cpuonly
fi
echo "${PYTORCH_MUTEX}"
echo '::endgroup::'
echo '::group::Create conda environment'
conda create --prefix $PWD/ci \
--quiet --yes \
python=${{ matrix.python-version }} \
numpy libpng jpeg scipy
conda activate $PWD/ci
echo '::endgroup::'
echo '::group::Install PyTorch'
conda install \
--quiet --yes \
-c "${PYTORCH_CHANNEL}" \
-c nvidia \
pytorch \
"${PYTORCH_MUTEX}"
if [[ ${{ matrix.gpu-arch-type }} = 'cuda' ]]; then
python3 -c "import torch; exit(not torch.cuda.is_available())"
fi
echo '::endgroup::'
echo '::group::Install TorchVision'
python setup.py develop
echo '::endgroup::'
echo '::group::Collect PyTorch environment information'
python -m torch.utils.collect_env
echo '::endgroup::'
echo '::group::Install testing utilities'
pip install --progress-bar=off pytest pytest-mock pytest-cov
echo '::endgroup::'
echo '::group::Run prototype tests'
# We don't want to run the prototype datasets tests. Since the positional glob into `pytest`, i.e.
# `test/test_prototype*.py` takes the highest priority, neither `--ignore` nor `--ignore-glob` can help us here.
rm test/test_prototype_datasets*.py
pytest \
--durations=25 \
--cov=torchvision/prototype \
--cov-report=term-missing \
test/test_prototype*.py
echo '::endgroup::'
name: tests
on:
pull_request:
jobs:
prototype:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- name: Set up python
uses: actions/setup-python@v3
with:
python-version: 3.7
- name: Upgrade system packages
run: python -m pip install --upgrade pip setuptools wheel
- name: Checkout repository
uses: actions/checkout@v3
- name: Install PyTorch nightly builds
run: pip install --progress-bar=off --pre torch --extra-index-url https://download.pytorch.org/whl/nightly/cpu/
- name: Install torchvision
run: pip install --progress-bar=off --no-build-isolation --editable .
- name: Install other prototype dependencies
run: pip install --progress-bar=off scipy pycocotools h5py
- name: Install test requirements
run: pip install --progress-bar=off pytest pytest-mock pytest-cov
- name: Mark setup as complete
id: setup
run: exit 0
- name: Run prototype datapoints tests
shell: bash
run: |
pytest \
--durations=20 \
--cov=torchvision/prototype/datapoints \
--cov-report=term-missing \
test/test_prototype_datapoints*.py
- name: Run prototype transforms tests
if: success() || ( failure() && steps.setup.conclusion == 'success' )
shell: bash
run: |
pytest \
--durations=20 \
--cov=torchvision/prototype/transforms \
--cov-report=term-missing \
test/test_prototype_transforms*.py
- name: Run prototype models tests
if: success() || ( failure() && steps.setup.conclusion == 'success' )
shell: bash
run: |
pytest \
--durations=20 \
--cov=torchvision/prototype/models \
--cov-report=term-missing \
test/test_prototype_models*.py
name: Prototype transforms unit-tests on Linux GPU
on:
pull_request:
push:
branches:
- nightly
- main
- release/*
workflow_dispatch:
env:
CHANNEL: "nightly"
jobs:
tests:
strategy:
matrix:
python_version: ["3.8"]
cuda_arch_version: ["11.6"]
fail-fast: false
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
with:
runner: linux.4xlarge.nvidia.gpu
repository: pytorch/vision
gpu-arch-type: cuda
gpu-arch-version: ${{ matrix.cuda_arch_version }}
timeout: 120
script: |
# Mark Build Directory Safe
git config --global --add safe.directory /__w/vision/vision
# Set up Environment Variables
export PYTHON_VERSION="${{ matrix.python_version }}"
export VERSION="${{ matrix.cuda_arch_version }}"
export CUDATOOLKIT="pytorch-cuda=${VERSION}"
# Set CHANNEL
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
export CHANNEL=test
else
export CHANNEL=nightly
fi
# Create Conda Env
conda create -yp ci_env python="${PYTHON_VERSION}" numpy libpng jpeg scipy
conda activate /work/ci_env
# Install PyTorch, Torchvision, and testing libraries
set -ex
conda install \
--yes \
-c "pytorch-${CHANNEL}" \
-c nvidia \
pytorch \
"${CUDATOOLKIT}"
python3 -c "import torch; exit(not torch.cuda.is_available())"
python3 setup.py develop
python3 -m pip install pytest pytest-mock pytest-cov
# Run Tests
python3 -m torch.utils.collect_env
python3 -m pytest \
--durations=20 \
--cov=torchvision/prototype/transforms \
--cov-report=term-missing \
test/test_prototype_transforms*.py
import enum
import importlib.machinery
import importlib.util
import inspect
import random
import re
from collections import defaultdict
from importlib.machinery import SourceFileLoader
from pathlib import Path
import numpy as np
......@@ -890,8 +891,16 @@ class TestAATransforms:
def import_transforms_from_references(reference):
ref_det_filepath = Path(__file__).parent.parent / "references" / reference / "transforms.py"
return SourceFileLoader(ref_det_filepath.stem, ref_det_filepath.as_posix()).load_module()
HERE = Path(__file__).parent
PROJECT_ROOT = HERE.parent
loader = importlib.machinery.SourceFileLoader(
"transforms", str(PROJECT_ROOT / "references" / reference / "transforms.py")
)
spec = importlib.util.spec_from_loader("transforms", loader)
module = importlib.util.module_from_spec(spec)
loader.exec_module(module)
return module
det_transforms = import_transforms_from_references("detection")
......
......@@ -625,10 +625,10 @@ def test_correctness_rotate_bounding_box(angle, expand, center):
)
transformed_points = np.matmul(points, affine_matrix.T)
out_bbox = [
np.min(transformed_points[:4, 0]),
np.min(transformed_points[:4, 1]),
np.max(transformed_points[:4, 0]),
np.max(transformed_points[:4, 1]),
float(np.min(transformed_points[:4, 0])),
float(np.min(transformed_points[:4, 1])),
float(np.max(transformed_points[:4, 0])),
float(np.max(transformed_points[:4, 1])),
]
if expand_:
tr_x = np.min(transformed_points[4:, 0])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment