Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/nms_oveflow_fp16
Browse files Browse the repository at this point in the history
  • Loading branch information
datumbox authored Feb 13, 2021
2 parents cd9bc45 + af97ec2 commit f1f2e45
Show file tree
Hide file tree
Showing 23 changed files with 1,070 additions and 393 deletions.
1,236 changes: 889 additions & 347 deletions .circleci/config.yml

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ binary_common: &binary_common
description: "Wheel only: what docker image to use"
type: string
default: "pytorch/manylinux-cuda101"
conda_docker_image:
description: "Conda only: what docker image to use"
type: string
default: "pytorch/conda-builder:cpu"
environment:
PYTHON_VERSION: << parameters.python_version >>
PYTORCH_VERSION: << parameters.pytorch_version >>
Expand Down Expand Up @@ -189,7 +193,7 @@ jobs:
binary_linux_conda:
<<: *binary_common
docker:
- image: "pytorch/conda-cuda"
- image: "<< parameters.conda_docker_image >>"
resource_class: 2xlarge+
steps:
- checkout_merge
Expand Down Expand Up @@ -411,7 +415,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 @@ -436,7 +444,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 @@ -513,7 +525,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
17 changes: 14 additions & 3 deletions .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@
import os.path


PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
CUDA_VERSION = ["10.1", "10.2", "11.2"]


def build_workflows(prefix='', filter_branch=None, upload=False, indentation=6, windows_latest_only=False):
w = []
for btype in ["wheel", "conda"]:
for os_type in ["linux", "macos", "win"]:
python_versions = PYTHON_VERSIONS
cu_versions_dict = {"linux": ["cpu", "cu92", "cu101", "cu102", "cu110"],
"win": ["cpu", "cu101", "cu102", "cu110"],
cu_versions_dict = {"linux": ["cpu", "cu101", "cu102", "cu112"],
"win": ["cpu", "cu101", "cu102", "cu112"],
"macos": ["cpu"]}
cu_versions = cu_versions_dict[os_type]
for python_version in python_versions:
Expand Down Expand Up @@ -99,6 +100,7 @@ def upload_doc_job(filter_branch):
"cu101": "pytorch/manylinux-cuda101",
"cu102": "pytorch/manylinux-cuda102",
"cu110": "pytorch/manylinux-cuda110",
"cu112": "pytorch/manylinux-cuda112",
}


Expand All @@ -109,6 +111,14 @@ def get_manylinux_image(cu_version):
return f"pytorch/manylinux-cuda{cu_suffix}"


def get_conda_image(cu_version):
if cu_version == "cpu":
return "pytorch/conda-builder:cpu"
if cu_version.startswith('cu'):
cu_suffix = cu_version[len('cu'):]
return f"pytorch/conda-builder:cuda{cu_suffix}"


def generate_base_workflow(base_workflow_name, python_version, cu_version,
unicode, os_type, btype, *, filter_branch=None):

Expand All @@ -123,6 +133,7 @@ def generate_base_workflow(base_workflow_name, python_version, cu_version,

if os_type != "win":
d["wheel_docker_image"] = get_manylinux_image(cu_version)
d["conda_docker_image"] = get_conda_image(cu_version)

if filter_branch is not None:
d["filters"] = {
Expand Down
4 changes: 2 additions & 2 deletions .circleci/unittest/linux/scripts/environment.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
channels:
- pytorch
- defaults
# using conda-forge for python v3.9+
- conda-forge
dependencies:
- numpy
- pytest
- pytest-cov
- codecov
- pip
- libpng
- jpeg
- ffmpeg=4.2
- ca-certificates
- pip:
- future
Expand Down
3 changes: 2 additions & 1 deletion .circleci/unittest/linux/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ else
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
cudatoolkit="cudatoolkit=${version}"
fi

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

printf "* Installing torchvision\n"
python setup.py develop
9 changes: 9 additions & 0 deletions .circleci/unittest/linux/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,13 @@ conda activate "${env_dir}"

# 3. Install Conda dependencies
printf "* Installing dependencies (except PyTorch)\n"
NUMPY_MIN_VER="1.11"
FFMPEG_PIN="=4.2"
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
NUMPY_MIN_VER="1.20"
FFMPEG_PIN=">=4.2"
fi

conda install -y -c conda-forge "numpy >=${NUMPY_MIN_VER}"
conda install -y -c pytorch "ffmpeg${FFMPEG_PIN}"
conda env update --file "${this_dir}/environment.yml" --prune
3 changes: 2 additions & 1 deletion .circleci/unittest/windows/scripts/environment.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
channels:
- pytorch
- defaults
# use conda-forge for python v3.9+
- conda-forge
dependencies:
- numpy
- pytest
- pytest-cov
- codecov
Expand Down
3 changes: 2 additions & 1 deletion .circleci/unittest/windows/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ else
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
cudatoolkit="cudatoolkit=${version}"
fi

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

printf "* Installing torchvision\n"
"$this_dir/vc_env_helper.bat" python setup.py develop
5 changes: 5 additions & 0 deletions .circleci/unittest/windows/scripts/setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ conda activate "${env_dir}"

# 3. Install Conda dependencies
printf "* Installing dependencies (except PyTorch)\n"
NUMPY_MIN_VER="1.11"
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
NUMPY_MIN_VER="1.20"
fi
conda install -y -c conda-forge "numpy >=${NUMPY_MIN_VER}"
conda env update --file "${this_dir}/environment.yml" --prune
28 changes: 26 additions & 2 deletions packaging/pkg_helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@ setup_cuda() {

# Now work out the CUDA settings
case "$CU_VERSION" in
cu112)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2"
else
export CUDA_HOME=/usr/local/cuda-11.2/
fi
export FORCE_CUDA=1
# Hard-coding gencode flags is temporary situation until
# https://github.com/pytorch/pytorch/pull/23408 lands
export NVCC_FLAGS="-gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_86,code=sm_86 -gencode=arch=compute_50,code=compute_50"
;;
cu110)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.0"
Expand Down Expand Up @@ -170,10 +181,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 @@ -189,6 +203,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 @@ -263,6 +278,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 All @@ -272,6 +290,9 @@ setup_conda_cudatoolkit_constraint() {
export CONDA_CUDATOOLKIT_CONSTRAINT=""
else
case "$CU_VERSION" in
cu112)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.2,<11.3 # [not osx]"
;;
cu110)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.0,<11.1 # [not osx]"
;;
Expand Down Expand Up @@ -307,6 +328,9 @@ setup_conda_cudatoolkit_plain_constraint() {
export CMAKE_USE_CUDA=0
else
case "$CU_VERSION" in
cu112)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=11.2"
;;
cu102)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=10.2"
;;
Expand Down
17 changes: 11 additions & 6 deletions packaging/torchvision/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ requirements:
build:
- {{ compiler('c') }} # [win]
- libpng
- jpeg
- ffmpeg =4.2 # [not win]
- jpeg <=9b
# NOTE: The only ffmpeg version that we build is actually 4.2
- ffmpeg >=4.2 # [not win]

host:
- python
- setuptools
- numpy >=1.20 # [py>=39]
- numpy >=1.11 # [py!=39]
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
{{ environ.get('CONDA_CPUONLY_FEATURE') }}

run:
- python
- libpng
- ffmpeg =4.2 # [not win]
- jpeg
- ffmpeg >=4.2 # [not win]
- jpeg <=9b
- pillow >=4.1.1
- numpy >=1.11
- numpy >=1.20 # [py>=39]
- numpy >=1.11 # [py!=39]
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}

Expand All @@ -50,7 +54,8 @@ test:
requires:
- pytest
- scipy
- av =8.0.1
- av >=8.0.1
- jpeg <=9b
- ca-certificates


Expand Down
18 changes: 18 additions & 0 deletions packaging/windows/internal/cuda_install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if %CUDA_VER% EQU 100 goto cuda100
if %CUDA_VER% EQU 101 goto cuda101
if %CUDA_VER% EQU 102 goto cuda102
if %CUDA_VER% EQU 110 goto cuda110
if %CUDA_VER% EQU 112 goto cuda112

echo CUDA %CUDA_VERSION_STR% is not supported
exit /b 1
Expand Down Expand Up @@ -107,6 +108,23 @@ if not exist "%SRC_DIR%\temp_build\cudnn-11.0-windows-x64-v8.0.4.30.zip" (

goto cuda_common

:cuda112

if not exist "%SRC_DIR%\temp_build\cuda_11.2.0_460.89_win10.exe" (
curl -k -L https://ossci-windows.s3.amazonaws.com/cuda_11.2.0_460.89_win10.exe --output "%SRC_DIR%\temp_build\cuda_11.2.0_460.89_win10.exe"
if errorlevel 1 exit /b 1
set "CUDA_SETUP_FILE=%SRC_DIR%\temp_build\cuda_11.2.0_460.89_win10.exe"
set "ARGS=nvcc_11.2 cuobjdump_11.2 nvprune_11.2 nvprof_11.2 cupti_11.2 cublas_11.2 cublas_dev_11.2 cudart_11.2 cufft_11.2 cufft_dev_11.2 curand_11.2 curand_dev_11.2 cusolver_11.2 cusolver_dev_11.2 cusparse_11.2 cusparse_dev_11.2 npp_11.2 npp_dev_11.2 nvrtc_11.2 nvrtc_dev_11.2 nvml_dev_11.2"
)

if not exist "%SRC_DIR%\temp_build\cudnn-11.2-windows-x64-v8.1.0.77.zip" (
curl -k -L http://s3.amazonaws.com/ossci-windows/cudnn-11.2-windows-x64-v8.1.0.77.zip --output "%SRC_DIR%\temp_build\cudnn-11.2-windows-x64-v8.1.0.77.zip"
if errorlevel 1 exit /b 1
set "CUDNN_SETUP_FILE=%SRC_DIR%\temp_build\cudnn-11.2-windows-x64-v8.1.0.77.zip"
)

goto cuda_common

:cuda_common

if not exist "%SRC_DIR%\temp_build\NvToolsExt.7z" (
Expand Down
7 changes: 7 additions & 0 deletions test/_utils_internal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os


# Get relative file path
# this returns relative path from current file.
def get_relative_path(curr_file, *path_components):
return os.path.join(os.path.dirname(curr_file), *path_components)
21 changes: 15 additions & 6 deletions test/common_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,15 @@
from numbers import Number
from torch._six import string_classes
from collections import OrderedDict
from _utils_internal import get_relative_path

import numpy as np
from PIL import Image

IS_PY39 = sys.version_info.major == 3 and sys.version_info.minor == 9
PY39_SEGFAULT_SKIP_MSG = "Segmentation fault with Python 3.9, see https://github.com/pytorch/vision/issues/3367"
PY39_SKIP = unittest.skipIf(IS_PY39, PY39_SEGFAULT_SKIP_MSG)


@contextlib.contextmanager
def get_tmp_dir(src=None, **kwargs):
Expand Down Expand Up @@ -106,19 +111,23 @@ def remove_prefix_suffix(text, prefix, suffix):
# lives, NOT where test/common_utils.py lives.
module_id = self.__class__.__module__
munged_id = remove_prefix_suffix(self.id(), module_id + ".", strip_suffix)
test_file = os.path.realpath(sys.modules[module_id].__file__)
expected_file = os.path.join(os.path.dirname(test_file),
"expect",
munged_id)

# Determine expected file based on environment
expected_file_base = get_relative_path(
os.path.realpath(sys.modules[module_id].__file__),
"expect")

# Set expected_file based on subname.
expected_file = os.path.join(expected_file_base, munged_id)
if subname:
expected_file += "_" + subname
expected_file += "_expect.pkl"

if not ACCEPT and not os.path.exists(expected_file):
raise RuntimeError(
("No expect file exists for {}; to accept the current output, run:\n"
"python {} {} --accept").format(os.path.basename(expected_file), __main__.__file__, munged_id))
f"No expect file exists for {os.path.basename(expected_file)} in {expected_file}; "
"to accept the current output, run:\n"
f"python {__main__.__file__} {munged_id} --accept")

return expected_file

Expand Down
Loading

0 comments on commit f1f2e45

Please sign in to comment.