diff --git a/.github/scripts/setup-env.sh b/.github/scripts/setup-env.sh index 3a9217e9ef8..635fdb2654a 100755 --- a/.github/scripts/setup-env.sh +++ b/.github/scripts/setup-env.sh @@ -14,23 +14,26 @@ case $(uname) in Darwin) OS_TYPE=macos ;; + MSYS*) + OS_TYPE=windows + ;; *) echo "Unknown OS type:" $(uname) exit 1 ;; esac -echo '::group::Uninstall system JPEG libraries on macOS' -# The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by default -# that interfere with our build. We uninstall them here and use the one from conda below. if [[ "${OS_TYPE}" == "macos" && $(uname -m) == x86_64 ]]; then + echo '::group::Uninstall system JPEG libraries on macOS' + # The x86 macOS runners, e.g. the GitHub Actions native "macos-12" runner, has some JPEG libraries installed by + # default that interfere with our build. We uninstall them here and use the one from conda below. JPEG_LIBS=$(brew list | grep jpeg) echo $JPEG_LIBS for lib in $JPEG_LIBS; do brew uninstall --ignore-dependencies --force $lib || true done + echo '::endgroup::' fi -echo '::endgroup::' echo '::group::Create build environment' # See https://github.com/pytorch/vision/issues/7296 for ffmpeg @@ -66,10 +69,24 @@ ltt install --progress-bar=off \ torch if [[ $GPU_ARCH_TYPE == 'cuda' ]]; then - python3 -c "import torch; exit(not torch.cuda.is_available())" + python -c "import torch; exit(not torch.cuda.is_available())" fi echo '::endgroup::' +if [[ "${OS_TYPE}" == "windows" ]]; then + echo '::group::Install third party dependencies prior to TorchVision install on Windows' + # `easy_install`, i.e. `python setup.py` has problems downloading the dependencies due to SSL. + # Thus, we install them upfront with `pip` to avoid that. + # Instead of fixing the SSL error, we can probably maintain this special case until we switch away from the deprecated + # `easy_install` anyway. + python setup.py egg_info + # The requires.txt cannot be used with `pip install -r` directly. The requirements are listed at the top and the + # optional dependencies come in non-standard syntax after a blank line. Thus, we just extract the header. + sed -e '/^$/,$d' *.egg-info/requires.txt > requirements.txt + pip install --progress-bar=off -r requirements.txt + echo '::endgroup::' +fi + echo '::group::Install TorchVision' python setup.py develop echo '::endgroup::' diff --git a/.github/scripts/unittest.sh b/.github/scripts/unittest.sh index 41c750ebce2..2a0b7154200 100755 --- a/.github/scripts/unittest.sh +++ b/.github/scripts/unittest.sh @@ -4,15 +4,11 @@ set -euo pipefail ./.github/scripts/setup-env.sh -# Prepare conda -CONDA_PATH=$(which conda) -eval "$(${CONDA_PATH} shell.bash hook)" -conda activate ci +# Activate conda environment +eval "$($(which conda) shell.bash hook)" && conda deactivate && conda activate ci echo '::group::Install testing utilities' pip install --progress-bar=off pytest pytest-mock pytest-cov echo '::endgroup::' -echo '::group::Run unittests' pytest --junit-xml="${RUNNER_TEST_RESULTS_DIR}/test-results.xml" -v --durations=25 -echo '::endgroup::' diff --git a/.github/workflows/test-windows.yml b/.github/workflows/test-windows.yml new file mode 100644 index 00000000000..dd663d9e939 --- /dev/null +++ b/.github/workflows/test-windows.yml @@ -0,0 +1,51 @@ +name: Tests on Windows + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + workflow_dispatch: + +jobs: + unittests: + strategy: + matrix: + python-version: + - "3.8" + - "3.9" + - "3.10" + - "3.11" + runner: ["windows.4xlarge"] + gpu-arch-type: ["cpu"] + # FIXME: enable this as soon as nvjpeg is available on the Windows runner +# include: +# - python-version: "3.8" +# runner: windows.8xlarge.nvidia.gpu +# gpu-arch-type: cuda +# gpu-arch-version: "11.7" + fail-fast: false + uses: pytorch/test-infra/.github/workflows/windows_job.yml@main + with: + repository: pytorch/vision + runner: ${{ matrix.runner }} + timeout: 120 + script: | + set -euxo pipefail + + export PYTHON_VERSION=${{ matrix.python-version }} + export GPU_ARCH_TYPE=${{ matrix.gpu-arch-type }} + export GPU_ARCH_VERSION=${{ matrix.gpu-arch-version }} + + # TODO: Port this to pytorch/test-infra/.github/workflows/windows_job.yml + export PATH="/c/Jenkins/Miniconda3/Scripts:${PATH}" + + if [[ $GPU_ARCH_TYPE == 'cuda' ]]; then + # TODO: This should be handled by the generic Windows job the same as its done by the generic Linux job + export CUDA_HOME="/c/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v${{ matrix.gpu-arch-version }}" + export CUDA_PATH="${CUDA_HOME}" + fi + + ./.github/scripts/unittest.sh