Skip to content

Commit a71ca96

Browse files
Joao Gomesfacebook-github-bot
Joao Gomes
authored andcommitted
[fbsync] [Nova] Migrate Linux CPU job to Generic Job (#6797)
Summary: * [Nova] Migrate Linux CPU job to Generic Job * branch ref for composite action job * move checkout step to separate job * added runs-on * nit fixes * no need to run conda sheel script thing * Channel is set inside the script * add remaining env vars * nit env var fix * cleanup * simplify unneeded jobs * name of the conda env should be the path * remove main ref to use PR Reviewed By: YosuaMichael Differential Revision: D40588164 fbshipit-source-id: 45aad3577f19edc8296bc0b97435ad510d46a436
1 parent 35bb0e6 commit a71ca96

File tree

1 file changed

+36
-49
lines changed

1 file changed

+36
-49
lines changed

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

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,57 +14,44 @@ env:
1414

1515
jobs:
1616
tests:
17-
name: "Unit-tests on Linux CPU"
18-
runs-on: [self-hosted, linux.12xlarge]
19-
container:
20-
image: pytorch/conda-builder:cpu
2117
strategy:
2218
matrix:
2319
py_vers: ["3.7", "3.8", "3.9", "3.10"]
2420
fail-fast: false
21+
uses: pytorch/test-infra/.github/workflows/linux_job.yml@main
22+
with:
23+
runner: linux.12xlarge
24+
repository: pytorch/vision
25+
script: |
26+
# Mark Build Directory Safe
27+
git config --global --add safe.directory /__w/vision/vision
2528
26-
steps:
27-
- name: Checkout repository
28-
uses: actions/checkout@v2
29-
- name: Set Release CHANNEL (for release)
30-
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
31-
run: |
32-
echo "CHANNEL=test" >> "$GITHUB_ENV"
33-
- name: Setup Conda
34-
shell: bash -l {0}
35-
env:
36-
ENV_NAME: conda-env-${{ github.run_id }}
37-
PY_VERS: ${{ matrix.py_vers }}
38-
run: |
39-
git config --global --add safe.directory /__w/vision/vision
40-
. ~/miniconda3/etc/profile.d/conda.sh
41-
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy
42-
echo "CONDA_RUN=conda run -p ${ENV_NAME}" >> "$GITHUB_ENV"
43-
- name: Install TorchVision
44-
shell: bash -l {0}
45-
env:
46-
VERSION: cpu
47-
CUDATOOLKIT: cpuonly
48-
run: |
49-
# Needed for JPEG library detection as setup.py detects conda presence
50-
# by running `shutil.which('conda')`
51-
export PATH=~/miniconda3/bin:$PATH
52-
set -ex
53-
${CONDA_RUN} conda install \
54-
--yes \
55-
-c "pytorch-${CHANNEL}" \
56-
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${VERSION}*"] \
57-
"${CUDATOOLKIT}"
58-
${CONDA_RUN} python3 setup.py develop
59-
${CONDA_RUN} python3 -m pip install pytest pytest-mock 'av<10'
60-
- name: Run tests
61-
shell: bash -l {0}
62-
env:
63-
ENV_NAME: conda-env-${{ github.run_id }}
64-
PY_VERS: ${{ matrix.py_vers }}
65-
run: |
66-
. ~/miniconda3/etc/profile.d/conda.sh
67-
set -ex
68-
${CONDA_RUN} python3 -m torch.utils.collect_env
69-
${CONDA_RUN} python3 -m pytest --junitxml=test-results/junit.xml -v --durations 20
70-
conda env remove -p ${ENV_NAME}
29+
# Set up Environment Variables
30+
export PYTHON_VERSION="${{ matrix.py_vers }}"
31+
export VERSION="cpu"
32+
export CUDATOOLKIT="cpuonly"
33+
34+
# Set CHANNEL
35+
if [[ (${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then
36+
export CHANNEL=test
37+
else
38+
export CHANNEL=nightly
39+
fi
40+
41+
# Create Conda Env
42+
conda create -yp ci_env python="${PYTHON_VERSION}" numpy libpng jpeg scipy
43+
conda activate /work/ci_env
44+
45+
# Install PyTorch, Torchvision, and testing libraries
46+
set -ex
47+
conda install \
48+
--yes \
49+
-c "pytorch-${CHANNEL}" \
50+
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${VERSION}*"] \
51+
"${CUDATOOLKIT}"
52+
python3 setup.py develop
53+
python3 -m pip install pytest pytest-mock 'av<10'
54+
55+
# Run Tests
56+
python3 -m torch.utils.collect_env
57+
python3 -m pytest --junitxml=test-results/junit.xml -v --durations 20

0 commit comments

Comments
 (0)