Commit bf491463 authored by limm's avatar limm
Browse files

add v0.19.1 release

parent e17f5ea2
# Optional list of dependencies required by the package
dependencies = ['torch']
dependencies = ["torch"]
# classification
from torchvision.models import get_model_weights, get_weight
from torchvision.models.alexnet import alexnet
from torchvision.models.densenet import densenet121, densenet169, densenet201, densenet161
from torchvision.models.inception import inception_v3
from torchvision.models.resnet import resnet18, resnet34, resnet50, resnet101, resnet152,\
resnext50_32x4d, resnext101_32x8d, wide_resnet50_2, wide_resnet101_2
from torchvision.models.squeezenet import squeezenet1_0, squeezenet1_1
from torchvision.models.vgg import vgg11, vgg13, vgg16, vgg19, vgg11_bn, vgg13_bn, vgg16_bn, vgg19_bn
from torchvision.models.convnext import convnext_base, convnext_large, convnext_small, convnext_tiny
from torchvision.models.densenet import densenet121, densenet161, densenet169, densenet201
from torchvision.models.efficientnet import (
efficientnet_b0,
efficientnet_b1,
efficientnet_b2,
efficientnet_b3,
efficientnet_b4,
efficientnet_b5,
efficientnet_b6,
efficientnet_b7,
efficientnet_v2_l,
efficientnet_v2_m,
efficientnet_v2_s,
)
from torchvision.models.googlenet import googlenet
from torchvision.models.shufflenetv2 import shufflenet_v2_x0_5, shufflenet_v2_x1_0
from torchvision.models.inception import inception_v3
from torchvision.models.maxvit import maxvit_t
from torchvision.models.mnasnet import mnasnet0_5, mnasnet0_75, mnasnet1_0, mnasnet1_3
from torchvision.models.mobilenetv2 import mobilenet_v2
from torchvision.models.mobilenetv3 import mobilenet_v3_large, mobilenet_v3_small
from torchvision.models.mnasnet import mnasnet0_5, mnasnet0_75, mnasnet1_0, \
mnasnet1_3
# segmentation
from torchvision.models.segmentation import fcn_resnet50, fcn_resnet101, \
deeplabv3_resnet50, deeplabv3_resnet101, deeplabv3_mobilenet_v3_large, lraspp_mobilenet_v3_large
from torchvision.models.optical_flow import raft_large, raft_small
from torchvision.models.regnet import (
regnet_x_16gf,
regnet_x_1_6gf,
regnet_x_32gf,
regnet_x_3_2gf,
regnet_x_400mf,
regnet_x_800mf,
regnet_x_8gf,
regnet_y_128gf,
regnet_y_16gf,
regnet_y_1_6gf,
regnet_y_32gf,
regnet_y_3_2gf,
regnet_y_400mf,
regnet_y_800mf,
regnet_y_8gf,
)
from torchvision.models.resnet import (
resnet101,
resnet152,
resnet18,
resnet34,
resnet50,
resnext101_32x8d,
resnext101_64x4d,
resnext50_32x4d,
wide_resnet101_2,
wide_resnet50_2,
)
from torchvision.models.segmentation import (
deeplabv3_mobilenet_v3_large,
deeplabv3_resnet101,
deeplabv3_resnet50,
fcn_resnet101,
fcn_resnet50,
lraspp_mobilenet_v3_large,
)
from torchvision.models.shufflenetv2 import (
shufflenet_v2_x0_5,
shufflenet_v2_x1_0,
shufflenet_v2_x1_5,
shufflenet_v2_x2_0,
)
from torchvision.models.squeezenet import squeezenet1_0, squeezenet1_1
from torchvision.models.swin_transformer import swin_b, swin_s, swin_t, swin_v2_b, swin_v2_s, swin_v2_t
from torchvision.models.vgg import vgg11, vgg11_bn, vgg13, vgg13_bn, vgg16, vgg16_bn, vgg19, vgg19_bn
from torchvision.models.video import (
mc3_18,
mvit_v1_b,
mvit_v2_s,
r2plus1d_18,
r3d_18,
s3d,
swin3d_b,
swin3d_s,
swin3d_t,
)
from torchvision.models.vision_transformer import vit_b_16, vit_b_32, vit_h_14, vit_l_16, vit_l_32
cmake_minimum_required(VERSION 3.4.1)
set(TARGET torchvision_ops)
project(${TARGET} CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(LIBTORCH_HEADER_ROOT ${LIBTORCH_HEADER_ROOT})
set(LIBRARY_OUTPUT_PATH ../lib)
......@@ -11,13 +11,6 @@ file(GLOB VISION_SRCS
../torchvision/csrc/ops/*.h
../torchvision/csrc/ops/*.cpp)
# Remove interpolate_aa sources as they are temporary code
# see https://github.com/pytorch/vision/pull/3761
# and using TensorIterator unavailable with iOS
list(REMOVE_ITEM VISION_SRCS "${CMAKE_CURRENT_LIST_DIR}/../torchvision/csrc/ops/cpu/interpolate_aa_kernels.cpp")
list(REMOVE_ITEM VISION_SRCS "${CMAKE_CURRENT_LIST_DIR}/../torchvision/csrc/ops/interpolate_aa.cpp")
list(REMOVE_ITEM VISION_SRCS "${CMAKE_CURRENT_LIST_DIR}/../torchvision/csrc/ops/interpolate_aa.h")
add_library(${TARGET} STATIC
${VISION_SRCS}
)
......
pytorch_version = '2.0.0'
Pod::Spec.new do |s|
s.name = 'LibTorchvision'
s.version = '0.15.1'
s.authors = 'PyTorch Team'
s.license = { :type => 'BSD' }
s.homepage = 'https://github.com/pytorch/vision'
s.source = { :http => "https://ossci-ios.s3.amazonaws.com/libtorchvision_ops_ios_#{s.version}.zip" }
s.summary = '"The C++ library of TorchVision ops for iOS'
s.description = <<-DESC
The C++ library of TorchVision ops for iOS.
This version (#{s.version}) requires the installation of LibTorch #{pytorch_version} or LibTorch-Lite #{pytorch_version}.
DESC
s.ios.deployment_target = '12.0'
s.vendored_libraries = 'install/lib/*.a'
s.user_target_xcconfig = {
'VALID_ARCHS' => 'x86_64 arm64',
'OTHER_LDFLAGS' => '$(inherited) -force_load "$(PODS_ROOT)/LibTorchvision/install/lib/libtorchvision_ops.a"',
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++14',
'CLANG_CXX_LIBRARY' => 'libc++'
}
s.library = ['c++', 'stdc++']
end
## Status
The iOS demo of TorchVision is currently unmaintained, untested and likely out-of-date.
This source diff could not be displayed because it is too large. You can view the blob instead.
import torch
import torchvision
from torch.utils.mobile_optimizer import optimize_for_mobile
from torchvision.models.detection import (
fasterrcnn_mobilenet_v3_large_320_fpn,
FasterRCNN_MobileNet_V3_Large_320_FPN_Weights,
)
print(torch.__version__)
model = torchvision.models.detection.fasterrcnn_mobilenet_v3_large_320_fpn(
pretrained=True,
model = fasterrcnn_mobilenet_v3_large_320_fpn(
weights=FasterRCNN_MobileNet_V3_Large_320_FPN_Weights.DEFAULT,
box_score_thresh=0.7,
rpn_post_nms_top_n_test=100,
rpn_score_thresh=0.4,
rpn_pre_nms_top_n_test=150)
rpn_pre_nms_top_n_test=150,
)
model.eval()
script_model = torch.jit.script(model)
......
# Torchvision maintainers guide
This document aims at documenting user-facing policies / principles used when
developing and maintaining torchvision. Other maintainer info (e.g. release
process) can be found in the meta-internal wiki.
### What is public and what is private?
For the Python API, torchvision largely follows the [PyTorch
policy](https://github.com/pytorch/pytorch/wiki/Public-API-definition-and-documentation)
which is consistent with other major packages
([numpy](https://numpy.org/neps/nep-0023-backwards-compatibility.html),
[scikit-learn](https://scikit-learn.org/dev/glossary.html#term-API) etc.).
We recognize that his policy is somewhat imperfect for some edge cases, and that
it's difficult to come up with an accurate technical definition. In broad terms,
which are usually well understood by users, the policy is that:
- modules that can be accessed without leading underscore are public
- objects in a public file that don't have a leading underscore are public
- class attributes are public iff they have no leading underscore
- the rest of the modules / objects / class attributes are considered private
The public API has backward-compatible (BC) guarantees defined in our
deprecation policy (see below). The private API has not BC guarantees.
For C++, code is private. For Meta employees: if a C++ change breaks fbcode, fix
fbcode or revert the change. We should be careful about models running in
production and relying on torchvision ops.
The `test` folder is not importable and is **private.** Even meta-internal
projects should *not* rely on it (it has happened in the past and is now
programmatically impossible).
The training references do not have BC guarantees. Breaking changes are
possible, but we should make sure that the tutorials are still running properly,
and that their intended narrative is preserved (by e.g. checking outputs,
etc.).
The rest of the folders (build, android, ios, etc.) are private and have no BC
guarantees.
### Deprecation policy.
Because they're disruptive, **deprecations should only be used sparingly**.
We largely follow the [PyTorch
policy](https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy):
breaking changes require a deprecation period of at least 2 versions.
Deprecations should clearly indicate their deadline in the docs and warning
messages. Avoid not committing to a deadline, or keeping deprecated APIs for too
long: it gives no incentive for users to update their code, sends conflicting
messages ("why was this API removed while this other one is still around?"), and
accumulates debt in the project.
### Should this attribute be public? Should this function be private?
When designing an API it’s not always obvious what should be exposed as public,
and what should be kept as a private implementation detail. The following
guidelines can be useful:
* Functional consistency throughout the library is a top priority, for users and
developers’ sake. In doubt and unless it’s clearly wrong, expose what other
similar classes expose.
* Think really hard about the users and their use-cases, and try to expose what
they would need to address those use-cases. Aggressively keep everything else
private. Remember that the “private -> public” direction is way smoother than
the “public -> private” one: in doubt, keep it private.
* When thinking about use-cases, the general API motto applies: make what’s
simple and common easy, and make what’s complex possible (80% / 20% rule).
There might be a ~1% left that’s not addressed: that’s OK. Also, **make what’s
wrong very hard**, if not impossible.
As a good practice, always create new files and even classes with a leading
underscore in their name. This way, everything is private by default and the
only public surface is explicitly present in an `__init__.py` file.
......@@ -3,12 +3,19 @@
files = torchvision
show_error_codes = True
pretty = True
allow_redefinition = True
no_implicit_optional = True
warn_redundant_casts = True
[mypy-torchvision.io._video_opt.*]
[mypy-torchvision.io.image.*]
ignore_errors = True
[mypy-torchvision.io.*]
[mypy-torchvision.io.video.*]
ignore_errors = True
[mypy-torchvision.io.video_reader]
ignore_errors = True
......@@ -16,11 +23,43 @@ ignore_errors = True
ignore_errors=True
[mypy-torchvision.models.detection.*]
[mypy-torchvision.models.detection.anchor_utils]
ignore_errors = True
[mypy-torchvision.models.detection.transform]
ignore_errors = True
[mypy-torchvision.models.detection.roi_heads]
ignore_errors = True
[mypy-torchvision.models.detection.faster_rcnn]
ignore_errors = True
[mypy-torchvision.models.quantization.*]
[mypy-torchvision.models.detection.mask_rcnn]
ignore_errors = True
[mypy-torchvision.models.detection.keypoint_rcnn]
ignore_errors = True
[mypy-torchvision.models.detection.retinanet]
ignore_errors = True
[mypy-torchvision.models.detection.ssd]
ignore_errors = True
[mypy-torchvision.models.detection.ssdlite]
ignore_errors = True
[mypy-torchvision.models.detection.fcos]
ignore_errors = True
......@@ -28,7 +67,15 @@ ignore_errors = True
ignore_errors = True
[mypy-torchvision.transforms.*]
[mypy-torchvision.transforms._functional_pil]
ignore_errors = True
[mypy-torchvision.transforms.functional.*]
ignore_errors = True
[mypy-torchvision.transforms.transforms.*]
ignore_errors = True
......@@ -52,10 +99,6 @@ ignore_missing_imports = True
ignore_missing_imports = True
[mypy-pandas.*]
ignore_missing_imports = True
[mypy-accimage.*]
ignore_missing_imports = True
......@@ -67,3 +110,15 @@ ignore_missing_imports = True
[mypy-defusedxml.*]
ignore_missing_imports = True
[mypy-torchdata.*]
ignore_missing_imports = True
[mypy-h5py.*]
ignore_missing_imports = True
[mypy-gdown.*]
ignore_missing_imports = True
# Building torchvision packages for release
## Anaconda packages
### Linux
```bash
nvidia-docker run -it --ipc=host --rm -v $(pwd):/remote soumith/conda-cuda bash
pushd remote/conda
./build_vision.sh 9.0
./build_vision.sh 10.0
./build_vision.sh cpu
# copy packages over to /remote
# exit docker
# anaconda upload -u pytorch torchvision*.bz2
```
### OSX
```bash
# create a fresh anaconda environment / install and activate it
conda install -y conda-build anaconda-client
./build_vision.sh cpu
# copy packages over to /remote
# exit docker
# anaconda upload -u pytorch torchvision*.bz2
```
### Windows
```bash
# Open `Git Bash` and change dir to `conda`
./build_vision.sh 9.0
./build_vision.sh 10.0
./build_vision.sh cpu
# copy packages to a output directory
# anaconda upload -u pytorch torchvision*.bz2
```
## Wheels
### Linux
pushd wheel
```bash
nvidia-docker run -it --ipc=host --rm -v $(pwd):/remote soumith/manylinux-cuda90:latest bash
cd remote
./linux_manywheel.sh cu90
rm -rf /usr/local/cuda*
./linux_manywheel.sh cpu
```
```bash
nvidia-docker run -it --ipc=host --rm -v $(pwd):/remote soumith/manylinux-cuda100:latest bash
cd remote
./linux_manywheel.sh cu100
```
wheels are in the folders `cpu`, `cu90`, `cu100`.
You can upload the `cu90` wheels to twine with `twine upload *.whl`.
Which wheels we upload depends on which wheels PyTorch uploads as default, and right now, it's `cu90`.
### OSX
```bash
pushd wheel
./osx_wheel.sh
```
### Windows
```cmd
set PYTORCH_REPO=pytorch
pushd windows
call build_vision.bat 90 0.3.0 1
call build_vision.bat 100 0.3.0 1
call build_vision.bat cpu 0.3.0 1
```
wheels are in the current folder.
You can upload them to twine with `twine upload *.whl`
#!/bin/bash
set -ex
PARALLELISM=8
if [ -n "$MAX_JOBS" ]; then
PARALLELISM=$MAX_JOBS
fi
if [[ "$(uname)" != Darwin && "$OSTYPE" != "msys" ]]; then
eval "$(./conda/bin/conda shell.bash hook)"
conda activate ./env
fi
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"
export BUILD_TYPE=conda
setup_env 0.10.0
export SOURCE_ROOT_DIR="$PWD"
setup_conda_pytorch_constraint
setup_conda_cudatoolkit_plain_constraint
if [[ "$OSTYPE" == "msys" ]]; then
conda install -yq conda-build cmake pillow>=5.3.0 future
pip install dataclasses
fi
setup_visual_studio_constraint
setup_junit_results_folder
conda install -yq pytorch=$PYTORCH_VERSION $CONDA_CUDATOOLKIT_CONSTRAINT $CONDA_CPUONLY_FEATURE -c "pytorch-${UPLOAD_CHANNEL}"
TORCH_PATH=$(dirname $(python -c "import torch; print(torch.__file__)"))
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
conda install -yq libpng jpeg
else
yum install -y libpng-devel libjpeg-turbo-devel
fi
mkdir cpp_build
pushd cpp_build
# Generate libtorchvision files
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch -DWITH_CUDA=$CMAKE_USE_CUDA
# Compile and install libtorchvision
if [[ "$OSTYPE" == "msys" ]]; then
"$script_dir/windows/internal/vc_env_helper.bat" "$script_dir/windows/internal/build_cmake.bat" $PARALLELISM
CONDA_PATH=$(dirname $(which python))
cp -r "C:/Program Files (x86)/torchvision/include/torchvision" $CONDA_PATH/include
else
make -j$PARALLELISM
make install
if [[ "$(uname)" == Darwin ]]; then
CONDA_PATH=$(dirname $(dirname $(which python)))
cp -r /usr/local/include/torchvision $CONDA_PATH/include/
export C_INCLUDE_PATH=/usr/local/include
export CPLUS_INCLUDE_PATH=/usr/local/include
fi
fi
popd
# Install torchvision locally
python setup.py develop
# Trace, compile and run project that uses Faster-RCNN
pushd test/tracing/frcnn
mkdir build
# Trace model
python trace_model.py
cp fasterrcnn_resnet50_fpn.pt build
cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch -DWITH_CUDA=$CMAKE_USE_CUDA
if [[ "$OSTYPE" == "msys" ]]; then
"$script_dir/windows/internal/vc_env_helper.bat" "$script_dir/windows/internal/build_frcnn.bat" $PARALLELISM
mv fasterrcnn_resnet50_fpn.pt Release
cd Release
export PATH=$(cygpath "C:/Program Files (x86)/torchvision/bin"):$(cygpath $TORCH_PATH)/lib:$PATH
else
make -j$PARALLELISM
fi
# Run traced program
./test_frcnn_tracing
# Compile and run the CPP example
popd
cd examples/cpp/hello_world
mkdir build
cd build
cmake .. -DTorch_DIR=$TORCH_PATH/share/cmake/Torch
if [[ "$OSTYPE" == "msys" ]]; then
"$script_dir/windows/internal/vc_env_helper.bat" "$script_dir/windows/internal/build_cpp_example.bat" $PARALLELISM
cd Release
else
make -j$PARALLELISM
fi
# Run CPP example
./hello-world
#!/bin/bash
set -ex
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"
export BUILD_TYPE=conda
setup_env 0.10.0
export SOURCE_ROOT_DIR="$PWD"
setup_conda_pytorch_constraint
setup_conda_cudatoolkit_constraint
setup_visual_studio_constraint
setup_junit_results_folder
conda build $CONDA_CHANNEL_FLAGS -c defaults -c conda-forge --no-anaconda-upload --python "$PYTHON_VERSION" packaging/torchvision
#!/bin/bash
set -ex
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. "$script_dir/pkg_helpers.bash"
export BUILD_TYPE=wheel
setup_env 0.10.0
setup_wheel_python
pip_install numpy pyyaml future ninja
setup_pip_pytorch_version
python setup.py clean
# Copy binaries to be included in the wheel distribution
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
python_exec="$(which python)"
bin_path=$(dirname $python_exec)
env_path=$(dirname $bin_path)
if [[ "$(uname)" == Darwin ]]; then
# Install delocate to relocate the required binaries
pip_install delocate
else
cp "$bin_path/Library/bin/libpng16.dll" torchvision
cp "$bin_path/Library/bin/libjpeg.dll" torchvision
fi
else
# Install auditwheel to get some inspection utilities
pip_install auditwheel
# Point to custom libraries
export LD_LIBRARY_PATH=$(pwd)/ext_libraries/lib:$LD_LIBRARY_PATH
export TORCHVISION_INCLUDE=$(pwd)/ext_libraries/include
export TORCHVISION_LIBRARY=$(pwd)/ext_libraries/lib
fi
download_copy_ffmpeg
if [[ "$OSTYPE" == "msys" ]]; then
IS_WHEEL=1 "$script_dir/windows/internal/vc_env_helper.bat" python setup.py bdist_wheel
else
IS_WHEEL=1 python setup.py bdist_wheel
fi
if [[ "$(uname)" == Darwin ]]; then
pushd dist/
python_exec="$(which python)"
bin_path=$(dirname $python_exec)
env_path=$(dirname $bin_path)
for whl in *.whl; do
DYLD_FALLBACK_LIBRARY_PATH="$env_path/lib/:$DYLD_FALLBACK_LIBRARY_PATH" delocate-wheel -v $whl
done
else
if [[ "$OSTYPE" == "msys" ]]; then
"$script_dir/windows/internal/vc_env_helper.bat" python $script_dir/wheel/relocate.py
else
LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" python $script_dir/wheel/relocate.py
fi
fi
#!/usr/bin/env bash
#
# Usage (run from root of project):
# TEST_INFRA_BRANCH=release/2.1 RELEASE_BRANCH=release/2.1 RELEASE_VERSION=2.1.0 packaging/cut_release.sh
#
# TEST_INFRA_BRANCH: The release branch of test-infra that houses all reusable
# workflows
#
# RELEASE_BRANCH: The name of the release branch for this repo
#
# RELEASE_VERSION: Version of this current release
set -eou pipefail
# Create and Check out to Release Branch
git checkout -b "${RELEASE_BRANCH}"
# Change all GitHub Actions to reference the test-infra release branch
# as opposed to main.
for i in .github/workflows/*.yml; do
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
sed -i '' -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
else
sed -i -e s#@main#@"${TEST_INFRA_BRANCH}"# $i;
sed -i -e s#test-infra-ref:[[:space:]]main#"test-infra-ref: ${TEST_INFRA_BRANCH}"# $i;
fi
done
# Update the Release Version in version.txt
echo "${RELEASE_VERSION}" >version.txt
# Optional
# git add ./github/workflows/*.yml version.txt
# git commit -m "[RELEASE-ONLY CHANGES] Branch Cut for Release {RELEASE_VERSION}"
# git push origin "${RELEASE_BRANCH}"
# A set of useful bash functions for common functionality we need to do in
# many build scripts
# Setup CUDA environment variables, based on CU_VERSION
#
# Inputs:
# CU_VERSION (cpu, cu92, cu100)
# NO_CUDA_PACKAGE (bool)
# BUILD_TYPE (conda, wheel)
#
# Outputs:
# VERSION_SUFFIX (e.g., "")
# PYTORCH_VERSION_SUFFIX (e.g., +cpu)
# WHEEL_DIR (e.g., cu100/)
# CUDA_HOME (e.g., /usr/local/cuda-9.2, respected by torch.utils.cpp_extension)
# FORCE_CUDA (respected by torchvision setup.py)
# NVCC_FLAGS (respected by torchvision setup.py)
#
# Precondition: CUDA versions are installed in their conventional locations in
# /usr/local/cuda-*
#
# NOTE: Why VERSION_SUFFIX versus PYTORCH_VERSION_SUFFIX? If you're building
# a package with CUDA on a platform we support CUDA on, VERSION_SUFFIX ==
# PYTORCH_VERSION_SUFFIX and everyone is happy. However, if you are building a
# package with only CPU bits (e.g., torchaudio), then VERSION_SUFFIX is always
# empty, but PYTORCH_VERSION_SUFFIX is +cpu (because that's how you get a CPU
# version of a Python package. But that doesn't apply if you're on OS X,
# since the default CU_VERSION on OS X is cpu.
setup_cuda() {
# First, compute version suffixes. By default, assume no version suffixes
export VERSION_SUFFIX=""
export PYTORCH_VERSION_SUFFIX=""
export WHEEL_DIR=""
# Wheel builds need suffixes (but not if they're on OS X, which never has suffix)
if [[ "$BUILD_TYPE" == "wheel" ]] && [[ "$(uname)" != Darwin ]]; then
# The default CUDA has no suffix
if [[ "$CU_VERSION" != "cu102" ]]; then
export PYTORCH_VERSION_SUFFIX="+$CU_VERSION"
fi
# Match the suffix scheme of pytorch, unless this package does not have
# CUDA builds (in which case, use default)
if [[ -z "$NO_CUDA_PACKAGE" ]]; then
export VERSION_SUFFIX="$PYTORCH_VERSION_SUFFIX"
export WHEEL_DIR="$CU_VERSION/"
fi
fi
# 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
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu111)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.1"
else
export CUDA_HOME=/usr/local/cuda-11.1/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0;8.6"
;;
cu110)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v11.0"
else
export CUDA_HOME=/usr/local/cuda-11.0/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5;8.0"
;;
cu102)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.2"
else
export CUDA_HOME=/usr/local/cuda-10.2/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5"
;;
cu101)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.1"
else
export CUDA_HOME=/usr/local/cuda-10.1/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5"
;;
cu100)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v10.0"
else
export CUDA_HOME=/usr/local/cuda-10.0/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0;7.5"
;;
cu92)
if [[ "$OSTYPE" == "msys" ]]; then
export CUDA_HOME="C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.2"
else
export CUDA_HOME=/usr/local/cuda-9.2/
fi
export FORCE_CUDA=1
export TORCH_CUDA_ARCH_LIST="3.5;5.0+PTX;6.0;7.0"
;;
cpu)
;;
rocm*)
export FORCE_CUDA=1
;;
*)
echo "Unrecognized CU_VERSION=$CU_VERSION"
exit 1
;;
esac
}
# Populate build version if necessary, and add version suffix
#
# Inputs:
# BUILD_VERSION (e.g., 0.2.0 or empty)
# VERSION_SUFFIX (e.g., +cpu)
#
# Outputs:
# BUILD_VERSION (e.g., 0.2.0.dev20190807+cpu)
#
# Fill BUILD_VERSION if it doesn't exist already with a nightly string
# Usage: setup_build_version 0.2.0
setup_build_version() {
if [[ -z "$BUILD_VERSION" ]]; then
export BUILD_VERSION="$1.dev$(date "+%Y%m%d")$VERSION_SUFFIX"
else
export BUILD_VERSION="$BUILD_VERSION$VERSION_SUFFIX"
fi
# Set build version based on tag if on tag
if [[ -n "${CIRCLE_TAG}" ]]; then
# Strip tag
export BUILD_VERSION="$(echo "${CIRCLE_TAG}" | sed -e 's/^v//' -e 's/-.*$//')${VERSION_SUFFIX}"
fi
}
# Set some useful variables for OS X, if applicable
setup_macos() {
if [[ "$(uname)" == Darwin ]]; then
export MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++
fi
}
# Top-level entry point for things every package will need to do
#
# Usage: setup_env 0.2.0
setup_env() {
setup_cuda
setup_build_version "$1"
setup_macos
}
# Function to retry functions that sometimes timeout or have flaky failures
retry () {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
# Inputs:
# PYTHON_VERSION (2.7, 3.5, 3.6, 3.7)
# UNICODE_ABI (bool)
#
# Outputs:
# PATH modified to put correct Python version in PATH
#
# Precondition: If Linux, you are in a soumith/manylinux-cuda* Docker image
setup_wheel_python() {
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
eval "$(conda shell.bash hook)"
conda env remove -n "env$PYTHON_VERSION" || true
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 ${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
case "$PYTHON_VERSION" in
2.7)
if [[ -n "$UNICODE_ABI" ]]; then
python_abi=cp27-cp27mu
else
python_abi=cp27-cp27m
fi
;;
3.5) python_abi=cp35-cp35m ;;
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
;;
esac
# Download all the dependencies required to compile image and video_reader
# extensions
mkdir -p ext_libraries
pushd ext_libraries
popd
export PATH="/opt/python/$python_abi/bin:$(pwd)/ext_libraries/bin:$PATH"
fi
}
# Install with pip a bit more robustly than the default
pip_install() {
retry pip install --progress-bar off "$@"
}
# Install torch with pip, respecting PYTORCH_VERSION, and record the installed
# version into PYTORCH_VERSION, if applicable
setup_pip_pytorch_version() {
if [[ -z "$PYTORCH_VERSION" ]]; then
# Install latest prerelease version of torch, per our nightlies, consistent
# with the requested cuda version
pip_install --pre torch -f "https://download.pytorch.org/whl/nightly/${WHEEL_DIR}torch_nightly.html"
if [[ "$CUDA_VERSION" == "cpu" ]]; then
# CUDA and CPU are ABI compatible on the CPU-only parts, so strip
# in this case
export PYTORCH_VERSION="$(pip show torch | grep ^Version: | sed 's/Version: *//' | sed 's/+.\+//')"
else
export PYTORCH_VERSION="$(pip show torch | grep ^Version: | sed 's/Version: *//')"
fi
else
pip_install "torch==$PYTORCH_VERSION$PYTORCH_VERSION_SUFFIX" \
-f "https://download.pytorch.org/whl/${CU_VERSION}/torch_stable.html" \
-f "https://download.pytorch.org/whl/${UPLOAD_CHANNEL}/${CU_VERSION}/torch_${UPLOAD_CHANNEL}.html"
fi
}
# Fill PYTORCH_VERSION with the latest conda nightly version, and
# CONDA_CHANNEL_FLAGS with appropriate flags to retrieve these versions
#
# You MUST have populated PYTORCH_VERSION_SUFFIX before hand.
setup_conda_pytorch_constraint() {
if [[ -z "$PYTORCH_VERSION" ]]; then
export CONDA_CHANNEL_FLAGS="-c pytorch-nightly -c pytorch"
export PYTORCH_VERSION="$(conda search --json 'pytorch[channel=pytorch-nightly]' | \
python -c "import os, sys, json, re; cuver = os.environ.get('CU_VERSION'); \
cuver_1 = cuver.replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
cuver_2 = (cuver[:-1] + '.' + cuver[-1]).replace('cu', 'cuda') if cuver != 'cpu' else cuver; \
print(re.sub(r'\\+.*$', '', \
[x['version'] for x in json.load(sys.stdin)['pytorch'] \
if (x['platform'] == 'darwin' or cuver_1 in x['fn'] or cuver_2 in x['fn']) \
and 'py' + os.environ['PYTHON_VERSION'] in x['fn']][-1]))")"
if [[ -z "$PYTORCH_VERSION" ]]; then
echo "PyTorch version auto detection failed"
echo "No package found for CU_VERSION=$CU_VERSION and PYTHON_VERSION=$PYTHON_VERSION"
exit 1
fi
else
export CONDA_CHANNEL_FLAGS="-c pytorch -c pytorch-${UPLOAD_CHANNEL}"
fi
if [[ "$CU_VERSION" == cpu ]]; then
export CONDA_PYTORCH_BUILD_CONSTRAINT="- pytorch==$PYTORCH_VERSION${PYTORCH_VERSION_SUFFIX}"
export CONDA_PYTORCH_CONSTRAINT="- pytorch==$PYTORCH_VERSION"
else
export CONDA_PYTORCH_BUILD_CONSTRAINT="- pytorch==${PYTORCH_VERSION}${PYTORCH_VERSION_SUFFIX}"
export CONDA_PYTORCH_CONSTRAINT="- pytorch==${PYTORCH_VERSION}${PYTORCH_VERSION_SUFFIX}"
fi
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
setup_conda_cudatoolkit_constraint() {
export CONDA_CPUONLY_FEATURE=""
if [[ "$(uname)" == Darwin ]]; then
export CONDA_CUDATOOLKIT_CONSTRAINT=""
else
case "$CU_VERSION" in
cu112)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.2,<11.3 # [not osx]"
;;
cu111)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.1,<11.2 # [not osx]"
;;
cu110)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=11.0,<11.1 # [not osx]"
;;
cu102)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.2,<10.3 # [not osx]"
;;
cu101)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.1,<10.2 # [not osx]"
;;
cu100)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=10.0,<10.1 # [not osx]"
;;
cu92)
export CONDA_CUDATOOLKIT_CONSTRAINT="- cudatoolkit >=9.2,<9.3 # [not osx]"
;;
cpu)
export CONDA_CUDATOOLKIT_CONSTRAINT=""
export CONDA_CPUONLY_FEATURE="- cpuonly"
;;
*)
echo "Unrecognized CU_VERSION=$CU_VERSION"
exit 1
;;
esac
fi
}
setup_conda_cudatoolkit_plain_constraint() {
export CONDA_CPUONLY_FEATURE=""
export CMAKE_USE_CUDA=1
if [[ "$(uname)" == Darwin ]]; then
export CONDA_CUDATOOLKIT_CONSTRAINT=""
export CMAKE_USE_CUDA=0
else
case "$CU_VERSION" in
cu112)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=11.2"
;;
cu111)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=11.1"
;;
cu102)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=10.2"
;;
cu101)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=10.1"
;;
cu100)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=10.0"
;;
cu92)
export CONDA_CUDATOOLKIT_CONSTRAINT="cudatoolkit=9.2"
;;
cpu)
export CONDA_CUDATOOLKIT_CONSTRAINT=""
export CONDA_CPUONLY_FEATURE="cpuonly"
export CMAKE_USE_CUDA=0
;;
*)
echo "Unrecognized CU_VERSION=$CU_VERSION"
exit 1
;;
esac
fi
}
# Build the proper compiler package before building the final package
setup_visual_studio_constraint() {
if [[ "$OSTYPE" == "msys" ]]; then
export VSTOOLCHAIN_PACKAGE=vs$VC_YEAR
conda build $CONDA_CHANNEL_FLAGS --no-anaconda-upload packaging/$VSTOOLCHAIN_PACKAGE
cp packaging/$VSTOOLCHAIN_PACKAGE/conda_build_config.yaml packaging/torchvision/conda_build_config.yaml
fi
}
setup_junit_results_folder() {
if [[ "$CI" == "true" ]]; then
export CONDA_PYTORCH_BUILD_RESULTS_DIRECTORY="${SOURCE_ROOT_DIR}/build_results/results.xml"
fi
}
download_copy_ffmpeg() {
if [[ "$OSTYPE" == "msys" ]]; then
# conda install -yq ffmpeg=4.2 -c pytorch
# curl -L -q https://anaconda.org/pytorch/ffmpeg/4.3/download/win-64/ffmpeg-4.3-ha925a31_0.tar.bz2 --output ffmpeg-4.3-ha925a31_0.tar.bz2
# bzip2 --decompress --stdout ffmpeg-4.3-ha925a31_0.tar.bz2 | tar -x --file=-
# cp Library/bin/*.dll ../torchvision
echo "FFmpeg is disabled currently on Windows"
else
if [[ "$(uname)" == Darwin ]]; then
conda install -yq ffmpeg=4.2 -c pytorch
conda install -yq wget
else
# pushd ext_libraries
# wget -q https://anaconda.org/pytorch/ffmpeg/4.2/download/linux-64/ffmpeg-4.2-hf484d3e_0.tar.bz2
# tar -xjvf ffmpeg-4.2-hf484d3e_0.tar.bz2
# rm -rf ffmpeg-4.2-hf484d3e_0.tar.bz2
# ldconfig
# which ffmpeg
# popd
echo "FFmpeg is disabled currently on Linux"
fi
fi
}
#!/bin/bash
LD_LIBRARY_PATH="/usr/local/lib:$CUDA_HOME/lib64:$LD_LIBRARY_PATH" python packaging/wheel/relocate.py
#!/bin/bash
if [[ "$(uname)" == Darwin ]]; then
# Uninstall Conflicting jpeg brew formulae
jpeg_packages=$(brew list | grep jpeg)
echo "Existing Jpeg-related Brew libraries"
echo $jpeg_packages
for pkg in $jpeg_packages; do
brew uninstall --ignore-dependencies --force $pkg || true
done
conda install -yq wget
fi
if [[ "$(uname)" == Darwin || "$OSTYPE" == "msys" ]]; then
# Install libpng from Anaconda (defaults)
conda install libpng -yq
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch
# Copy binaries to be included in the wheel distribution
if [[ "$OSTYPE" == "msys" ]]; then
python_exec="$(which python)"
bin_path=$(dirname $python_exec)
cp "$bin_path/Library/bin/libjpeg.dll" torchvision
fi
else
if [[ "$ARCH" == "aarch64" ]]; then
conda install libpng -yq
conda install -yq ffmpeg=4.2 libjpeg-turbo -c pytorch-nightly
fi
# Install native CentOS libJPEG, freetype and GnuTLS
yum install -y libjpeg-turbo-devel freetype gnutls
# Download all the dependencies required to compile image and video_reader
# extensions
mkdir -p ext_libraries
pushd ext_libraries
popd
export PATH="$(pwd)/ext_libraries/bin:$PATH"
pip install auditwheel
# Point to custom libraries
export LD_LIBRARY_PATH=$(pwd)/ext_libraries/lib:$LD_LIBRARY_PATH
export TORCHVISION_INCLUDE=$(pwd)/ext_libraries/include
export TORCHVISION_LIBRARY=$(pwd)/ext_libraries/lib
fi
pip install numpy pyyaml future ninja
pip install --upgrade setuptools==72.1.0
......@@ -7,8 +7,7 @@ c_compiler:
cxx_compiler:
- vs2017 # [win]
python:
- 3.5
- 3.6
- 3.8
# This differs from target_platform in that it determines what subdir the compiler
# will target, not what subdir the compiler package will be itself.
# For example, we need a win-64 vs2008_win-32 package, so that we compile win-32
......
{% set build_variant = environ.get('CONDA_BUILD_VARIANT', 'cpu') %}
package:
name: torchvision
version: "{{ environ.get('BUILD_VERSION') }}"
......@@ -9,27 +10,36 @@ requirements:
build:
- {{ compiler('c') }} # [win]
- libpng
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
# NOTE: The only ffmpeg version that we build is actually 4.2
- ffmpeg >=4.2 # [not win]
- libjpeg-turbo
- ffmpeg >=4.2.2, <5.0.0 # [linux]
host:
- python
- setuptools
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_BUILD_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
run:
- python
- defaults::numpy >=1.11 # [py <= 310]
- numpy >=1.23.5 # [py >= 311]
- requests
- libpng
- ffmpeg >=4.2 # [not win]
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- pillow >=5.3.0
{{ environ.get('CONDA_PYTORCH_CONSTRAINT') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT') }}
- ffmpeg >=4.2.2, <5.0.0 # [linux]
- libjpeg-turbo
- pillow >=5.3.0, !=8.3.*
- pytorch-mutex 1.0 {{ build_variant }} # [not osx ]
{{ environ.get('CONDA_PYTORCH_CONSTRAINT', 'pytorch') }}
{{ environ.get('CONDA_CUDATOOLKIT_CONSTRAINT', '') }}
{% if build_variant == 'cpu' %}
run_constrained:
- cpuonly
{% elif not osx %}
run_constrained:
- cpuonly <0
{% endif %}
build:
string: py{{py}}_{{ environ['CU_VERSION'] }}
......@@ -39,8 +49,7 @@ build:
- FORCE_CUDA
- BUILD_VERSION
- TORCH_CUDA_ARCH_LIST
features:
{{ environ.get('CONDA_CPUONLY_FEATURE') }}
- MACOSX_DEPLOYMENT_TARGET
test:
imports:
......@@ -52,9 +61,7 @@ test:
requires:
- pytest
- scipy
- av
# NOTE: Pinned to fix issues with size_t on Windows
- jpeg <=9b
- libjpeg-turbo
- ca-certificates
......
:: Set env vars that tell distutils to use the compiler that we put on path
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
SET "VS_VERSION=15.0"
SET "VS_MAJOR=15"
SET "VS_YEAR=2017"
set "MSYS2_ARG_CONV_EXCL=/AI;/AL;/OUT;/out"
set "MSYS2_ENV_CONV_EXCL=CL"
:: For Python 3.5+, ensure that we link with the dynamic runtime. See
:: http://stevedower.id.au/blog/building-for-python-3-5-part-two/ for more info
set "PY_VCRUNTIME_REDIST=%PREFIX%\\bin\\vcruntime140.dll"
for /f "usebackq tokens=*" %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -legacy -products * -version [15^,16^) -property installationPath`) do (
if exist "%%i" if exist "%%i\VC\Auxiliary\Build\vcvarsall.bat" (
set "VSINSTALLDIR=%%i\"
goto :vswhere
)
)
:vswhere
:: Shorten PATH to avoid the `input line too long` error.
SET MyPath=%PATH%
setlocal EnableDelayedExpansion
SET TempPath="%MyPath:;=";"%"
SET var=
FOR %%a IN (%TempPath%) DO (
IF EXIST %%~sa (
SET "var=!var!;%%~sa"
)
)
set "TempPath=!var:~1!"
endlocal & set "PATH=%TempPath%"
:: Shorten current directory too
FOR %%A IN (.) DO CD "%%~sA"
:: other things added by install_activate.bat at package build time
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment