|
| 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::' |
0 commit comments