Skip to content

Commit

Permalink
[v0.8.X] .circleci: Add Python 3.9 to CI (pytorch#3063)
Browse files Browse the repository at this point in the history
# Conflicts:
#	.circleci/config.yml
#	.circleci/config.yml.in
#	.circleci/unittest/linux/scripts/environment.yml
#	.circleci/unittest/windows/scripts/environment.yml
#	packaging/torchvision/meta.yaml
  • Loading branch information
datumbox committed Jan 15, 2021
1 parent 7bf6e7b commit c0485a7
Show file tree
Hide file tree
Showing 10 changed files with 911 additions and 123 deletions.
954 changes: 849 additions & 105 deletions .circleci/config.yml

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,11 @@ jobs:
set -x
eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
conda env remove -n python${PYTHON_VERSION} || true
conda create -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
CONDA_CHANNEL_FLAGS=""
if [[ "${PYTHON_VERSION}" = 3.9 ]]; then
CONDA_CHANNEL_FLAGS="-c=conda-forge"
fi
conda create ${CONDA_CHANNEL_FLAGS} -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
conda activate python${PYTHON_VERSION}
conda install Pillow
conda install -v -y -c pytorch-nightly pytorch
Expand All @@ -426,7 +430,11 @@ jobs:
command: |
set -x
eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
conda env remove -n python${PYTHON_VERSION} || true
CONDA_CHANNEL_FLAGS=""
if [[ "${PYTHON_VERSION}" = 3.9 ]]; then
CONDA_CHANNEL_FLAGS="-c=conda-forge"
fi
conda create ${CONDA_CHANNEL_FLAGS} -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
conda create -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
conda activate python${PYTHON_VERSION}
pip install $(ls ~/workspace/torchvision*.whl) --pre -f https://download.pytorch.org/whl/nightly/torch_nightly.html
Expand Down Expand Up @@ -491,9 +499,14 @@ jobs:
name: Generate cache key
# This will refresh cache on Sundays, nightly build should generate new cache.
command: echo "$(date +"%Y-%U")" > .circleci-weekly
- restore_cache:
{% raw %}
keys:
- env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
{% endraw %}
- run:
name: Setup
command: docker run -e PYTHON_VERSION -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/setup_env.sh
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e PYTHON_VERSION "${image_name}" .circleci/unittest/linux/scripts/setup_env.sh
- save_cache:
{% raw %}
key: env-v2-linux-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/linux/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
Expand All @@ -503,7 +516,7 @@ jobs:
- env
- run:
name: Install torchvision
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL "${image_name}" .circleci/unittest/linux/scripts/install.sh
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL -e CU_VERSION "${image_name}" .circleci/unittest/linux/scripts/install.sh
- run:
name: Run tests
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh
Expand Down Expand Up @@ -565,6 +578,11 @@ jobs:
name: Generate cache key
# This will refresh cache on Sundays, nightly build should generate new cache.
command: echo "$(date +"%Y-%U")" > .circleci-weekly
- restore_cache:
{% raw %}
keys:
- env-v1-windows-{{ arch }}-py<< parameters.python_version >>-{{ checksum ".circleci/unittest/windows/scripts/environment.yml" }}-{{ checksum ".circleci-weekly" }}
{% endraw %}
- run:
name: Setup
command: .circleci/unittest/windows/scripts/setup_env.sh
Expand Down
2 changes: 1 addition & 1 deletion .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import os.path


PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]


def build_workflows(prefix='', filter_branch=None, upload=False, indentation=6, windows_latest_only=False):
Expand Down
6 changes: 4 additions & 2 deletions .circleci/unittest/linux/scripts/environment.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
channels:
- pytorch
- defaults
# using conda-forge for python v3.9+
- conda-forge
dependencies:
- numpy
- pytest
- pytest-cov
- codecov
- pip
- libpng
- jpeg
- jpeg <= 9b
- ffmpeg=4.2
- ca-certificates
- av
- pip:
- future
- pillow>=4.1.1
- scipy
- av
8 changes: 7 additions & 1 deletion .circleci/unittest/linux/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ else
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
cudatoolkit="cudatoolkit=${version}"
fi

CONDA_CHANNEL_FLAGS=""
if [[ "$(python --version)" = *3.9* ]]; then
CONDA_CHANNEL_FLAGS="-c=conda-forge"
fi

printf "Installing PyTorch with %s\n" "${cudatoolkit}"
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch "${cudatoolkit}"
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" ${CONDA_CHANNEL_FLAGS} pytorch "${cudatoolkit}"

printf "* Installing torchvision\n"
python setup.py develop
8 changes: 5 additions & 3 deletions .circleci/unittest/windows/scripts/environment.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
channels:
- pytorch
- defaults
# use conda-forge for python v3.9+
- conda-forge
dependencies:
- numpy
- pytest
- pytest-cov
- codecov
- pip
- libpng
- jpeg
- jpeg <= 9b
- ca-certificates
- av
- pip:
- future
- pillow>=4.1.1
- scipy
- av
- scipy>=1.4.1
- dataclasses
8 changes: 7 additions & 1 deletion .circleci/unittest/windows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ else
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
cudatoolkit="cudatoolkit=${version}"
fi

CONDA_CHANNEL_FLAGS=""
if [[ "$(python --version)" = *3.9* ]]; then
CONDA_CHANNEL_FLAGS="-c=conda-forge"
fi

printf "Installing PyTorch with %s\n" "${cudatoolkit}"
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch "${cudatoolkit}"
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" ${CONDA_CHANNEL_FLAGS} pytorch "${cudatoolkit}"

printf "* Installing torchvision\n"
"$this_dir/vc_env_helper.bat" python setup.py develop
11 changes: 9 additions & 2 deletions packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,13 @@ setup_wheel_python() {
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
eval "$(conda shell.bash hook)"
conda env remove -n "env$PYTHON_VERSION" || true
conda create -yn "env$PYTHON_VERSION" python="$PYTHON_VERSION"
if [[ "$PYTHON_VERSION" == 3.9 ]]; then
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c=conda-forge"
fi
conda create ${CONDA_CHANNEL_FLAGS} -yn "env$PYTHON_VERSION" python="$PYTHON_VERSION"
conda activate "env$PYTHON_VERSION"
# Install libpng from Anaconda (defaults)
conda install libpng jpeg -y
conda install ${CONDA_CHANNEL_FLAGS} -c conda-forge libpng "jpeg<=9b" -y
else
# Install native CentOS libJPEG, LAME, freetype and GnuTLS
yum install -y libjpeg-turbo-devel lame freetype gnutls
Expand All @@ -198,6 +201,7 @@ setup_wheel_python() {
3.6) python_abi=cp36-cp36m ;;
3.7) python_abi=cp37-cp37m ;;
3.8) python_abi=cp38-cp38 ;;
3.9) python_abi=cp39-cp39 ;;
*)
echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION"
exit 1
Expand Down Expand Up @@ -272,6 +276,9 @@ setup_conda_pytorch_constraint() {
if [[ "$OSTYPE" == msys && "$CU_VERSION" == cu92 ]]; then
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c defaults -c numba/label/dev"
fi
if [[ "$PYTHON_VERSION" == 3.9 ]]; then
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c=conda-forge"
fi
}

# Translate CUDA_VERSION into CUDA_CUDATOOLKIT_CONSTRAINT
Expand Down
7 changes: 4 additions & 3 deletions packaging/torchvision/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ requirements:
build:
- {{ compiler('c') }} # [win]
- libpng
- jpeg
- jpeg <=9b
- ffmpeg =4.2 # [not win]

host:
Expand All @@ -23,7 +23,7 @@ requirements:
- python
- libpng
- ffmpeg =4.2 # [not win]
- jpeg
- jpeg <=9b
- pillow >=4.1.1
- numpy >=1.11
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
Expand All @@ -50,7 +50,8 @@ test:
requires:
- pytest
- scipy
- av =8.0.1
- av >=8.0.1
- jpeg <=9b
- ca-certificates
{{ environ.get('CONDA_TYPING_CONSTRAINT') }}

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,9 @@ def get_extensions():
))

ffmpeg_exe = distutils.spawn.find_executable('ffmpeg')
has_ffmpeg = ffmpeg_exe is not None
# Disable ffmpeg by default
no_ffmpeg = os.environ.get("NO_FFMPEG", True)
has_ffmpeg = ffmpeg_exe is not None and not no_ffmpeg
print("FFmpeg found: {}".format(has_ffmpeg))

if has_ffmpeg:
Expand Down

0 comments on commit c0485a7

Please sign in to comment.