Skip to content

Commit f2122e8

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] consolidate Linux workflows on CPU and GPU (#7189)
Reviewed By: vmoens Differential Revision: D44416540 fbshipit-source-id: 13d9ced6c5723b1cf99d8a45a38683c09f51c533
1 parent 89b5a09 commit f2122e8

File tree

4 files changed

+120
-119
lines changed

4 files changed

+120
-119
lines changed

.github/unittest.sh

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
# Prepare conda
6+
CONDA_PATH=$(which conda)
7+
eval "$(${CONDA_PATH} shell.bash hook)"
8+
conda config --set channel_priority strict
9+
10+
echo '::group::Set PyTorch conda channel and wheel index'
11+
# TODO: Can we maybe have this as environment variable in the job template? For example, `IS_RELEASE`.
12+
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
13+
CHANNEL_ID=test
14+
else
15+
CHANNEL_ID=nightly
16+
fi
17+
PYTORCH_CONDA_CHANNEL=pytorch-"${CHANNEL_ID}"
18+
echo "PYTORCH_CONDA_CHANNEL=${PYTORCH_CONDA_CHANNEL}"
19+
20+
case $GPU_ARCH_TYPE in
21+
cpu)
22+
GPU_ARCH_ID="cpu"
23+
;;
24+
cuda)
25+
VERSION_WITHOUT_DOT=$(echo "${GPU_ARCH_VERSION}" | sed 's/\.//')
26+
GPU_ARCH_ID="cu${VERSION_WITHOUT_DOT}"
27+
;;
28+
*)
29+
echo "Unknown GPU_ARCH_TYPE=${GPU_ARCH_TYPE}"
30+
exit 1
31+
;;
32+
esac
33+
PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/${CHANNEL_ID}/${GPU_ARCH_ID}"
34+
echo "PYTORCH_WHEEL_INDEX=${PYTORCH_WHEEL_INDEX}"
35+
echo '::endgroup::'
36+
37+
echo '::group::Create build environment'
38+
# See https://github.com/pytorch/vision/issues/7296 for ffmpeg
39+
conda create \
40+
--name ci \
41+
--quiet --yes \
42+
python="${PYTHON_VERSION}" pip \
43+
ninja libpng jpeg \
44+
'ffmpeg<4.3' \
45+
-c "${PYTORCH_CONDA_CHANNEL}" \
46+
-c defaults
47+
conda activate ci
48+
pip install --progress-bar=off --upgrade setuptools
49+
50+
# See https://github.com/pytorch/vision/issues/6790
51+
if [[ "${PYTHON_VERSION}" != "3.11" ]]; then
52+
pip install --progress-bar=off av!=10.0.0
53+
fi
54+
55+
echo '::endgroup::'
56+
57+
echo '::group::Install PyTorch'
58+
pip install --progress-bar=off --pre torch --index-url="${PYTORCH_WHEEL_INDEX}"
59+
60+
if [[ $GPU_ARCH_TYPE == 'cuda' ]]; then
61+
python3 -c "import torch; exit(not torch.cuda.is_available())"
62+
fi
63+
echo '::endgroup::'
64+
65+
echo '::group::Install TorchVision'
66+
python setup.py develop
67+
echo '::endgroup::'
68+
69+
echo '::group::Collect PyTorch environment information'
70+
python -m torch.utils.collect_env
71+
echo '::endgroup::'
72+
73+
echo '::group::Install testing utilities'
74+
pip install --progress-bar=off pytest pytest-mock pytest-cov
75+
echo '::endgroup::'
76+
77+
echo '::group::Run tests'
78+
pytest --durations=25
79+
echo '::endgroup::'

.github/workflows/test-linux-cpu.yml

-58
This file was deleted.

.github/workflows/test-linux-gpu.yml

-61
This file was deleted.

.github/workflows/test-linux.yml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Unit-tests on Linux
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
jobs:
13+
tests:
14+
strategy:
15+
matrix:
16+
python-version:
17+
- "3.8"
18+
- "3.9"
19+
- "3.10"
20+
- "3.11"
21+
runner: ["linux.12xlarge"]
22+
gpu-arch-type: ["cpu"]
23+
include:
24+
- python-version: 3.8
25+
runner: linux.g5.4xlarge.nvidia.gpu
26+
gpu-arch-type: cuda
27+
gpu-arch-version: "11.7"
28+
fail-fast: false
29+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
30+
with:
31+
repository: pytorch/vision
32+
runner: ${{ matrix.runner }}
33+
gpu-arch-type: ${{ matrix.gpu-arch-type }}
34+
gpu-arch-version: ${{ matrix.gpu-arch-version }}
35+
timeout: 120
36+
script: |
37+
export PYTHON_VERSION=${{ matrix.python-version }}
38+
export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }}
39+
export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }}
40+
41+
./.github/unittest.sh

0 commit comments

Comments
 (0)