Skip to content

Commit 1b673fd

Browse files
authored
Updated wheel packaging for building nightlies. (#1197)
Signed-off-by: Edward Z. Yang <[email protected]>
1 parent 6a834e9 commit 1b673fd

File tree

2 files changed

+50
-11
lines changed

2 files changed

+50
-11
lines changed

packaging/wheel/linux_manywheel.sh

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1+
#!/bin/bash
2+
set -ex
3+
14
if [ "$#" -ne 1 ]; then
25
echo "Illegal number of parameters. Pass cuda version"
3-
echo "CUDA version should be cu90, cu100 or cpu"
6+
echo "CUDA version should be cu92, cu100 or cpu"
47
exit 1
58
fi
6-
export CUVER="$1" # cu90 cu100 cpu
9+
export CUVER="$1" # cu92 cu100 cpu
10+
11+
if [[ "$CUVER" == "cu100" ]]; then
12+
cu_suffix=""
13+
else
14+
cu_suffix="+$CUVER"
15+
fi
716

8-
export TORCHVISION_BUILD_VERSION="0.3.0"
17+
export TORCHVISION_BUILD_VERSION="0.4.0.dev$(date "+%Y%m%d")${cu_suffix}"
918
export TORCHVISION_BUILD_NUMBER="1"
19+
export TORCHVISION_LOCAL_VERSION_LABEL="$CUVER"
1020
export OUT_DIR="/remote/$CUVER"
11-
export TORCH_WHEEL="torch -f https://download.pytorch.org/whl/$CUVER/stable.html --no-index"
1221

1322
pushd /opt/python
1423
DESIRED_PYTHON=(*/)
@@ -18,12 +27,33 @@ for desired_py in "${DESIRED_PYTHON[@]}"; do
1827
done
1928

2029
OLD_PATH=$PATH
21-
git clone https://github.com/pytorch/vision -b v${TORCHVISION_BUILD_VERSION}
22-
pushd vision
30+
cd /tmp
31+
rm -rf vision
32+
git clone https://github.com/pytorch/vision
33+
34+
cd /tmp/vision
35+
2336
for PYDIR in "${python_installations[@]}"; do
2437
export PATH=$PYDIR/bin:$OLD_PATH
38+
pip install --upgrade pip
2539
pip install numpy pyyaml future
26-
pip install $TORCH_WHEEL
40+
41+
pip uninstall -y torch || true
42+
pip uninstall -y torch_nightly || true
43+
44+
export TORCHVISION_PYTORCH_DEPENDENCY_NAME=torch_nightly
45+
pip install torch_nightly -f https://download.pytorch.org/whl/nightly/$CUVER/torch_nightly.html
46+
# CPU/CUDA variants of PyTorch have ABI compatible PyTorch for
47+
# the CPU only bits. Therefore, we
48+
# strip off the local package qualifier, but ONLY if we're
49+
# doing a CPU build.
50+
if [[ "$CUVER" == "cpu" ]]; then
51+
export TORCHVISION_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//' | sed 's/+.\+//')"
52+
else
53+
export TORCHVISION_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//')"
54+
fi
55+
echo "Building against ${TORCHVISION_PYTORCH_DEPENDENCY_VERSION}"
56+
2757
pip install ninja
2858
python setup.py clean
2959
python setup.py bdist_wheel

setup.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_dist(pkgname):
2929
return None
3030

3131

32-
version = '0.3.0a0'
32+
version = '0.4.0a0'
3333
sha = 'Unknown'
3434
package_name = os.getenv('TORCHVISION_PACKAGE_NAME', 'torchvision')
3535

@@ -43,9 +43,13 @@ def get_dist(pkgname):
4343
if os.getenv('TORCHVISION_BUILD_VERSION'):
4444
assert os.getenv('TORCHVISION_BUILD_NUMBER') is not None
4545
build_number = int(os.getenv('TORCHVISION_BUILD_NUMBER'))
46-
version = os.getenv('TORCHVISION_BUILD_VERSION')
46+
base_version = os.getenv('TORCHVISION_BUILD_VERSION')
47+
version = base_version
4748
if build_number > 1:
4849
version += '.post' + str(build_number)
50+
local_label = os.getenv('TORCHVISION_LOCAL_VERSION_LABEL')
51+
if local_label is not None:
52+
version += '+' + local_label
4953
elif sha != 'Unknown':
5054
version += '+' + sha[:7]
5155
print("Building wheel {}-{}".format(package_name, version))
@@ -65,12 +69,17 @@ def write_version_file():
6569

6670
readme = open('README.rst').read()
6771

68-
pytorch_package_name = os.getenv('TORCHVISION_PYTORCH_DEPENDENCY_NAME', 'torch')
72+
pytorch_dep = os.getenv('TORCHVISION_PYTORCH_DEPENDENCY_NAME', 'torch')
73+
if os.getenv('TORCHVISION_PYTORCH_DEPENDENCY_VERSION'):
74+
pytorch_dep += "==" + os.getenv('TORCHVISION_PYTORCH_DEPENDENCY_VERSION')
75+
# torchvision has CUDA bits, thus, we must specify a local dependency
76+
if local_label is not None:
77+
pytorch_dep += '+' + local_label
6978

7079
requirements = [
7180
'numpy',
7281
'six',
73-
pytorch_package_name,
82+
pytorch_dep,
7483
]
7584

7685
pillow_ver = ' >= 4.1.1'

0 commit comments

Comments
 (0)