Skip to content

Commit 87c13ee

Browse files
Joao Gomesfacebook-github-bot
Joao Gomes
authored andcommitted
[fbsync] [Nova] Add GHA Linux CPU Unittests for Torchvision (#6759)
Summary: * [Nova][WIP] Add Linux CPU Unittests for Torchvision * use conda-builder image since conda installation is needed * install torch dep with conda instead * use circleCI command to run tests * larger instance to avoid OOM issues * proper syntax for self-hosted runners * 4xlarge instance * 8xlarge * 12xlarge * use setup-miniconda job * add back PATH change to help setup py detect conda * run conda shell script * install other deps up front * git config and undo path change * revert to local conda install * conda-builder image * support for whole python version matrix * clean up the conda env once we are done with the job Reviewed By: YosuaMichael Differential Revision: D40588169 fbshipit-source-id: 515b12daa84d1707f6b700782fade13f8532ff05
1 parent c3e132a commit 87c13ee

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Unit-tests on Linux CPU
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
env:
13+
CHANNEL: "nightly"
14+
15+
jobs:
16+
tests:
17+
name: "Unit-tests on Linux CPU"
18+
runs-on: [self-hosted, linux.12xlarge]
19+
container:
20+
image: pytorch/conda-builder:cpu
21+
strategy:
22+
matrix:
23+
py_vers: ["3.7", "3.8", "3.9", "3.10"]
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
- name: Set Release CHANNEL (for release)
29+
if: ${{ (github.event_name == 'pull_request' && startsWith(github.base_ref, 'release')) || startsWith(github.ref, 'refs/heads/release') }}
30+
run: |
31+
echo "CHANNEL=test" >> "$GITHUB_ENV"
32+
- name: Setup Conda
33+
shell: bash -l {0}
34+
env:
35+
ENV_NAME: conda-env-${{ github.run_id }}
36+
PY_VERS: ${{ matrix.py_vers }}
37+
run: |
38+
git config --global --add safe.directory /__w/vision/vision
39+
. ~/miniconda3/etc/profile.d/conda.sh
40+
conda create -yp ${ENV_NAME} python=${PY_VERS} numpy libpng jpeg scipy
41+
echo "CONDA_RUN=conda run -p ${ENV_NAME}" >> "$GITHUB_ENV"
42+
- name: Install TorchVision
43+
shell: bash -l {0}
44+
env:
45+
VERSION: cpu
46+
CUDATOOLKIT: cpuonly
47+
run: |
48+
# Needed for JPEG library detection as setup.py detects conda presence
49+
# by running `shutil.which('conda')`
50+
export PATH=~/miniconda3/bin:$PATH
51+
set -ex
52+
${CONDA_RUN} conda install \
53+
--yes \
54+
-c "pytorch-${CHANNEL}" \
55+
-c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${VERSION}*"] \
56+
"${CUDATOOLKIT}"
57+
${CONDA_RUN} python3 setup.py develop
58+
${CONDA_RUN} python3 -m pip install pytest pytest-mock av
59+
- name: Run tests
60+
shell: bash -l {0}
61+
env:
62+
ENV_NAME: conda-env-${{ github.run_id }}
63+
PY_VERS: ${{ matrix.py_vers }}
64+
run: |
65+
. ~/miniconda3/etc/profile.d/conda.sh
66+
set -ex
67+
${CONDA_RUN} python3 -m torch.utils.collect_env
68+
${CONDA_RUN} python3 -m pytest --junitxml=test-results/junit.xml -v --durations 20
69+
conda env remove -p ${ENV_NAME}

0 commit comments

Comments
 (0)