Skip to content

Commit f1f2e45

Browse files
authored
Merge branch 'master' into bugfix/nms_oveflow_fp16
2 parents cd9bc45 + af97ec2 commit f1f2e45

23 files changed

+1070
-393
lines changed

.circleci/config.yml

Lines changed: 889 additions & 347 deletions
Large diffs are not rendered by default.

.circleci/config.yml.in

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ binary_common: &binary_common
7373
description: "Wheel only: what docker image to use"
7474
type: string
7575
default: "pytorch/manylinux-cuda101"
76+
conda_docker_image:
77+
description: "Conda only: what docker image to use"
78+
type: string
79+
default: "pytorch/conda-builder:cpu"
7680
environment:
7781
PYTHON_VERSION: << parameters.python_version >>
7882
PYTORCH_VERSION: << parameters.pytorch_version >>
@@ -189,7 +193,7 @@ jobs:
189193
binary_linux_conda:
190194
<<: *binary_common
191195
docker:
192-
- image: "pytorch/conda-cuda"
196+
- image: "<< parameters.conda_docker_image >>"
193197
resource_class: 2xlarge+
194198
steps:
195199
- checkout_merge
@@ -411,7 +415,11 @@ jobs:
411415
set -x
412416
eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
413417
conda env remove -n python${PYTHON_VERSION} || true
414-
conda create -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
418+
CONDA_CHANNEL_FLAGS=""
419+
if [[ "${PYTHON_VERSION}" = 3.9 ]]; then
420+
CONDA_CHANNEL_FLAGS="-c=conda-forge"
421+
fi
422+
conda create ${CONDA_CHANNEL_FLAGS} -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
415423
conda activate python${PYTHON_VERSION}
416424
conda install Pillow
417425
conda install -v -y -c pytorch-nightly pytorch
@@ -436,7 +444,11 @@ jobs:
436444
command: |
437445
set -x
438446
eval "$('/C/tools/miniconda3/Scripts/conda.exe' 'shell.bash' 'hook')"
439-
conda env remove -n python${PYTHON_VERSION} || true
447+
CONDA_CHANNEL_FLAGS=""
448+
if [[ "${PYTHON_VERSION}" = 3.9 ]]; then
449+
CONDA_CHANNEL_FLAGS="-c=conda-forge"
450+
fi
451+
conda create ${CONDA_CHANNEL_FLAGS} -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
440452
conda create -yn python${PYTHON_VERSION} python=${PYTHON_VERSION}
441453
conda activate python${PYTHON_VERSION}
442454
pip install $(ls ~/workspace/torchvision*.whl) --pre -f https://download.pytorch.org/whl/nightly/torch_nightly.html
@@ -513,7 +525,7 @@ jobs:
513525
- env
514526
- run:
515527
name: Install torchvision
516-
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD -e UPLOAD_CHANNEL "${image_name}" .circleci/unittest/linux/scripts/install.sh
528+
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
517529
- run:
518530
name: Run tests
519531
command: docker run -t --gpus all -v $PWD:$PWD -w $PWD "${image_name}" .circleci/unittest/linux/scripts/run_test.sh

.circleci/regenerate.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,17 @@
1919
import os.path
2020

2121

22-
PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]
22+
PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"]
23+
CUDA_VERSION = ["10.1", "10.2", "11.2"]
2324

2425

2526
def build_workflows(prefix='', filter_branch=None, upload=False, indentation=6, windows_latest_only=False):
2627
w = []
2728
for btype in ["wheel", "conda"]:
2829
for os_type in ["linux", "macos", "win"]:
2930
python_versions = PYTHON_VERSIONS
30-
cu_versions_dict = {"linux": ["cpu", "cu92", "cu101", "cu102", "cu110"],
31-
"win": ["cpu", "cu101", "cu102", "cu110"],
31+
cu_versions_dict = {"linux": ["cpu", "cu101", "cu102", "cu112"],
32+
"win": ["cpu", "cu101", "cu102", "cu112"],
3233
"macos": ["cpu"]}
3334
cu_versions = cu_versions_dict[os_type]
3435
for python_version in python_versions:
@@ -99,6 +100,7 @@ def upload_doc_job(filter_branch):
99100
"cu101": "pytorch/manylinux-cuda101",
100101
"cu102": "pytorch/manylinux-cuda102",
101102
"cu110": "pytorch/manylinux-cuda110",
103+
"cu112": "pytorch/manylinux-cuda112",
102104
}
103105

104106

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

111113

114+
def get_conda_image(cu_version):
115+
if cu_version == "cpu":
116+
return "pytorch/conda-builder:cpu"
117+
if cu_version.startswith('cu'):
118+
cu_suffix = cu_version[len('cu'):]
119+
return f"pytorch/conda-builder:cuda{cu_suffix}"
120+
121+
112122
def generate_base_workflow(base_workflow_name, python_version, cu_version,
113123
unicode, os_type, btype, *, filter_branch=None):
114124

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

124134
if os_type != "win":
125135
d["wheel_docker_image"] = get_manylinux_image(cu_version)
136+
d["conda_docker_image"] = get_conda_image(cu_version)
126137

127138
if filter_branch is not None:
128139
d["filters"] = {

.circleci/unittest/linux/scripts/environment.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
channels:
22
- pytorch
33
- defaults
4+
# using conda-forge for python v3.9+
5+
- conda-forge
46
dependencies:
5-
- numpy
67
- pytest
78
- pytest-cov
89
- codecov
910
- pip
1011
- libpng
1112
- jpeg
12-
- ffmpeg=4.2
1313
- ca-certificates
1414
- pip:
1515
- future

.circleci/unittest/linux/scripts/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ else
2222
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
2323
cudatoolkit="cudatoolkit=${version}"
2424
fi
25+
2526
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
26-
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch "${cudatoolkit}"
27+
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" -c conda-forge pytorch "${cudatoolkit}"
2728

2829
printf "* Installing torchvision\n"
2930
python setup.py develop

.circleci/unittest/linux/scripts/setup_env.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,13 @@ conda activate "${env_dir}"
3636

3737
# 3. Install Conda dependencies
3838
printf "* Installing dependencies (except PyTorch)\n"
39+
NUMPY_MIN_VER="1.11"
40+
FFMPEG_PIN="=4.2"
41+
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
42+
NUMPY_MIN_VER="1.20"
43+
FFMPEG_PIN=">=4.2"
44+
fi
45+
46+
conda install -y -c conda-forge "numpy >=${NUMPY_MIN_VER}"
47+
conda install -y -c pytorch "ffmpeg${FFMPEG_PIN}"
3948
conda env update --file "${this_dir}/environment.yml" --prune

.circleci/unittest/windows/scripts/environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
channels:
22
- pytorch
33
- defaults
4+
# use conda-forge for python v3.9+
5+
- conda-forge
46
dependencies:
5-
- numpy
67
- pytest
78
- pytest-cov
89
- codecov

.circleci/unittest/windows/scripts/install.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ else
2424
version="$(python -c "print('.'.join(\"${CUDA_VERSION}\".split('.')[:2]))")"
2525
cudatoolkit="cudatoolkit=${version}"
2626
fi
27+
2728
printf "Installing PyTorch with %s\n" "${cudatoolkit}"
28-
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" pytorch "${cudatoolkit}"
29+
conda install -y -c "pytorch-${UPLOAD_CHANNEL}" -c conda-forge pytorch "${cudatoolkit}"
2930

3031
printf "* Installing torchvision\n"
3132
"$this_dir/vc_env_helper.bat" python setup.py develop

.circleci/unittest/windows/scripts/setup_env.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,9 @@ conda activate "${env_dir}"
3636

3737
# 3. Install Conda dependencies
3838
printf "* Installing dependencies (except PyTorch)\n"
39+
NUMPY_MIN_VER="1.11"
40+
if [[ "${PYTHON_VERSION}" = "3.9" ]]; then
41+
NUMPY_MIN_VER="1.20"
42+
fi
43+
conda install -y -c conda-forge "numpy >=${NUMPY_MIN_VER}"
3944
conda env update --file "${this_dir}/environment.yml" --prune

packaging/pkg_helpers.bash

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ setup_cuda() {
4949

5050
# Now work out the CUDA settings
5151
case "$CU_VERSION" in
52+
cu112)
53+
if [[ "$OSTYPE" == "msys" ]]; then
54+
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.2"
55+
else
56+
export CUDA_HOME=/usr/local/cuda-11.2/
57+
fi
58+
export FORCE_CUDA=1
59+
# Hard-coding gencode flags is temporary situation until
60+
# https://github.com/pytorch/pytorch/pull/23408 lands
61+
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"
62+
;;
5263
cu110)
5364
if [[ "$OSTYPE" == "msys" ]]; then
5465
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.0"
@@ -170,10 +181,13 @@ setup_wheel_python() {
170181
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
171182
eval "$(conda shell.bash hook)"
172183
conda env remove -n "env$PYTHON_VERSION" || true
173-
conda create -yn "env$PYTHON_VERSION" python="$PYTHON_VERSION"
184+
if [[ "$PYTHON_VERSION" == 3.9 ]]; then
185+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c=conda-forge"
186+
fi
187+
conda create ${CONDA_CHANNEL_FLAGS} -yn "env$PYTHON_VERSION" python="$PYTHON_VERSION"
174188
conda activate "env$PYTHON_VERSION"
175189
# Install libpng from Anaconda (defaults)
176-
conda install libpng jpeg -y
190+
conda install ${CONDA_CHANNEL_FLAGS} -c conda-forge libpng "jpeg<=9b" -y
177191
else
178192
# Install native CentOS libJPEG, LAME, freetype and GnuTLS
179193
yum install -y libjpeg-turbo-devel lame freetype gnutls
@@ -189,6 +203,7 @@ setup_wheel_python() {
189203
3.6) python_abi=cp36-cp36m ;;
190204
3.7) python_abi=cp37-cp37m ;;
191205
3.8) python_abi=cp38-cp38 ;;
206+
3.9) python_abi=cp39-cp39 ;;
192207
*)
193208
echo "Unrecognized PYTHON_VERSION=$PYTHON_VERSION"
194209
exit 1
@@ -263,6 +278,9 @@ setup_conda_pytorch_constraint() {
263278
if [[ "$OSTYPE" == msys && "$CU_VERSION" == cu92 ]]; then
264279
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c defaults -c numba/label/dev"
265280
fi
281+
if [[ "$PYTHON_VERSION" == 3.9 ]]; then
282+
export CONDA_CHANNEL_FLAGS="${CONDA_CHANNEL_FLAGS} -c=conda-forge"
283+
fi
266284
}
267285

268286
# Translate CUDA_VERSION into CUDA_CUDATOOLKIT_CONSTRAINT
@@ -272,6 +290,9 @@ setup_conda_cudatoolkit_constraint() {
272290
export CONDA_CUDATOOLKIT_CONSTRAINT=""
273291
else
274292
case "$CU_VERSION" in
293+
cu112)
294+
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.2,<11.3 # [not osx]"
295+
;;
275296
cu110)
276297
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.0,<11.1 # [not osx]"
277298
;;
@@ -307,6 +328,9 @@ setup_conda_cudatoolkit_plain_constraint() {
307328
export CMAKE_USE_CUDA=0
308329
else
309330
case "$CU_VERSION" in
331+
cu112)
332+
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=11.2"
333+
;;
310334
cu102)
311335
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=10.2"
312336
;;

packaging/torchvision/meta.yaml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,27 @@ requirements:
99
build:
1010
- {{ compiler('c') }} # [win]
1111
- libpng
12-
- jpeg
13-
- ffmpeg =4.2 # [not win]
12+
- jpeg <=9b
13+
# NOTE: The only ffmpeg version that we build is actually 4.2
14+
- ffmpeg >=4.2 # [not win]
1415

1516
host:
1617
- python
1718
- setuptools
19+
- numpy >=1.20 # [py>=39]
20+
- numpy >=1.11 # [py!=39]
1821
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
1922
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
2023
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
2124

2225
run:
2326
- python
2427
- libpng
25-
- ffmpeg =4.2 # [not win]
26-
- jpeg
28+
- ffmpeg >=4.2 # [not win]
29+
- jpeg <=9b
2730
- pillow >=4.1.1
28-
- numpy >=1.11
31+
- numpy >=1.20 # [py>=39]
32+
- numpy >=1.11 # [py!=39]
2933
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
3034
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
3135

@@ -50,7 +54,8 @@ test:
5054
requires:
5155
- pytest
5256
- scipy
53-
- av =8.0.1
57+
- av >=8.0.1
58+
- jpeg <=9b
5459
- ca-certificates
5560

5661

packaging/windows/internal/cuda_install.bat

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ if %CUDA_VER% EQU 100 goto cuda100
1919
if %CUDA_VER% EQU 101 goto cuda101
2020
if %CUDA_VER% EQU 102 goto cuda102
2121
if %CUDA_VER% EQU 110 goto cuda110
22+
if %CUDA_VER% EQU 112 goto cuda112
2223

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

108109
goto cuda_common
109110

111+
:cuda112
112+
113+
if not exist "%SRC_DIR%\temp_build\cuda_11.2.0_460.89_win10.exe" (
114+
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"
115+
if errorlevel 1 exit /b 1
116+
set "CUDA_SETUP_FILE=%SRC_DIR%\temp_build\cuda_11.2.0_460.89_win10.exe"
117+
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"
118+
)
119+
120+
if not exist "%SRC_DIR%\temp_build\cudnn-11.2-windows-x64-v8.1.0.77.zip" (
121+
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"
122+
if errorlevel 1 exit /b 1
123+
set "CUDNN_SETUP_FILE=%SRC_DIR%\temp_build\cudnn-11.2-windows-x64-v8.1.0.77.zip"
124+
)
125+
126+
goto cuda_common
127+
110128
:cuda_common
111129

112130
if not exist "%SRC_DIR%\temp_build\NvToolsExt.7z" (

test/_utils_internal.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
3+
4+
# Get relative file path
5+
# this returns relative path from current file.
6+
def get_relative_path(curr_file, *path_components):
7+
return os.path.join(os.path.dirname(curr_file), *path_components)

test/common_utils.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
from numbers import Number
1515
from torch._six import string_classes
1616
from collections import OrderedDict
17+
from _utils_internal import get_relative_path
1718

1819
import numpy as np
1920
from PIL import Image
2021

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

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

115+
# Determine expected file based on environment
116+
expected_file_base = get_relative_path(
117+
os.path.realpath(sys.modules[module_id].__file__),
118+
"expect")
119+
120+
# Set expected_file based on subname.
121+
expected_file = os.path.join(expected_file_base, munged_id)
114122
if subname:
115123
expected_file += "_" + subname
116124
expected_file += "_expect.pkl"
117125

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

123132
return expected_file
124133

0 commit comments

Comments
 (0)