Skip to content

Commit 5c5a94d

Browse files
authored
enable Windows CPU CI on GHA (#7475)
1 parent 781f512 commit 5c5a94d

File tree

3 files changed

+75
-11
lines changed

3 files changed

+75
-11
lines changed

.github/scripts/setup-env.sh

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,26 @@ case $(uname) in
1414
Darwin)
1515
OS_TYPE=macos
1616
;;
17+
MSYS*)
18+
OS_TYPE=windows
19+
;;
1720
*)
1821
echo "Unknown OS type:" $(uname)
1922
exit 1
2023
;;
2124
esac
2225

23-
echo '::group::Uninstall system JPEG libraries on macOS'
24-
# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by default
25-
# that interfere with our build. We uninstall them here and use the one from conda below.
2626
if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then
27+
echo '::group::Uninstall system JPEG libraries on macOS'
28+
# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by
29+
# default that interfere with our build. We uninstall them here and use the one from conda below.
2730
JPEG_LIBS=$(brew list | grep jpeg)
2831
echo $JPEG_LIBS
2932
for lib in $JPEG_LIBS; do
3033
brew uninstall --ignore-dependencies --force $lib || true
3134
done
35+
echo '::endgroup::'
3236
fi
33-
echo '::endgroup::'
3437

3538
echo '::group::Create build environment'
3639
# See https://github.com/pytorch/vision/issues/7296 for ffmpeg
@@ -66,10 +69,24 @@ ltt install --progress-bar=off \
6669
torch
6770

6871
if [[ $GPU_ARCH_TYPE == 'cuda' ]]; then
69-
python3 -c "import torch; exit(not torch.cuda.is_available())"
72+
python -c "import torch; exit(not torch.cuda.is_available())"
7073
fi
7174
echo '::endgroup::'
7275

76+
if [[ "${OS_TYPE}" == "windows" ]]; then
77+
echo '::group::Install third party dependencies prior to TorchVision install on Windows'
78+
# `easy_install`, i.e. `python setup.py` has problems downloading the dependencies due to SSL.
79+
# Thus, we install them upfront with `pip` to avoid that.
80+
# Instead of fixing the SSL error, we can probably maintain this special case until we switch away from the deprecated
81+
# `easy_install` anyway.
82+
python setup.py egg_info
83+
# The requires.txt cannot be used with `pip install -r` directly. The requirements are listed at the top and the
84+
# optional dependencies come in non-standard syntax after a blank line. Thus, we just extract the header.
85+
sed -e '/^$/,$d' *.egg-info/requires.txt > requirements.txt
86+
pip install --progress-bar=off -r requirements.txt
87+
echo '::endgroup::'
88+
fi
89+
7390
echo '::group::Install TorchVision'
7491
python setup.py develop
7592
echo '::endgroup::'

.github/scripts/unittest.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ set -euo pipefail
44

55
./.github/scripts/setup-env.sh
66

7-
# Prepare conda
8-
CONDA_PATH=$(which conda)
9-
eval "$(${CONDA_PATH} shell.bash hook)"
10-
conda activate ci
7+
# Activate conda environment
8+
eval "$($(which conda) shell.bash hook)" && conda deactivate && conda activate ci
119

1210
echo '::group::Install testing utilities'
1311
pip install --progress-bar=off pytest pytest-mock pytest-cov
1412
echo '::endgroup::'
1513

16-
echo '::group::Run unittests'
1714
pytest --junit-xml="${RUNNER_TEST_RESULTS_DIR}/test-results.xml" -v --durations=25
18-
echo '::endgroup::'

.github/workflows/test-windows.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Tests on Windows
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- nightly
8+
- main
9+
- release/*
10+
workflow_dispatch:
11+
12+
jobs:
13+
unittests:
14+
strategy:
15+
matrix:
16+
python-version:
17+
- "3.8"
18+
- "3.9"
19+
- "3.10"
20+
- "3.11"
21+
runner: ["windows.4xlarge"]
22+
gpu-arch-type: ["cpu"]
23+
# FIXME: enable this as soon as nvjpeg is available on the Windows runner
24+
# include:
25+
# - python-version: "3.8"
26+
# runner: windows.8xlarge.nvidia.gpu
27+
# gpu-arch-type: cuda
28+
# gpu-arch-version: "11.7"
29+
fail-fast: false
30+
uses: pytorch/test-infra/.github/workflows/windows_job.yml@main
31+
with:
32+
repository: pytorch/vision
33+
runner: ${{ matrix.runner }}
34+
timeout: 120
35+
script: |
36+
set -euxo pipefail
37+
38+
export PYTHON_VERSION=${{ matrix.python-version }}
39+
export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }}
40+
export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }}
41+
42+
# TODO: Port this to pytorch/test-infra/.github/workflows/windows_job.yml
43+
export PATH="/c/Jenkins/Miniconda3/Scripts:${PATH}"
44+
45+
if [[ $GPU_ARCH_TYPE == 'cuda' ]]; then
46+
# TODO: This should be handled by the generic Windows job the same as its done by the generic Linux job
47+
export CUDA_HOME="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${{ matrix.gpu-arch-version }}"
48+
export CUDA_PATH="${CUDA_HOME}"
49+
fi
50+
51+
./.github/scripts/unittest.sh

0 commit comments

Comments
 (0)