linux_manywheel.sh 1.79 KB
Newer Older
1
2
3
#!/bin/bash
set -ex

4
5
if [ "$#" -ne 1 ]; then
    echo "Illegal number of parameters. Pass cuda version"
6
    echo "CUDA version should be cu92, cu100 or cpu"
7
8
    exit 1
fi
9
export CUVER="$1" # cu[0-9]* cpu
10

11
if [[ "$CUVER" == "cu102" ]]; then
12
13
14
15
  cu_suffix=""
else
  cu_suffix="+$CUVER"
fi
16

17
export TORCHVISION_BUILD_VERSION="0.4.0.dev$(date "+%Y%m%d")${cu_suffix}"
18
export TORCHVISION_BUILD_NUMBER="1"
19
export TORCHVISION_LOCAL_VERSION_LABEL="$CUVER"
20
21
22
23
24
25
26
27
28
29
export OUT_DIR="/remote/$CUVER"

pushd /opt/python
DESIRED_PYTHON=(*/)
popd
for desired_py in "${DESIRED_PYTHON[@]}"; do
    python_installations+=("/opt/python/$desired_py")
done

OLD_PATH=$PATH
30
31
32
33
34
35
cd /tmp
rm -rf vision
git clone https://github.com/pytorch/vision

cd /tmp/vision

36
37
for PYDIR in "${python_installations[@]}"; do
    export PATH=$PYDIR/bin:$OLD_PATH
38
    pip install --upgrade pip
39
    pip install numpy pyyaml future
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56

    pip uninstall -y torch || true
    pip uninstall -y torch_nightly || true

    export TORCHVISION_PYTORCH_DEPENDENCY_NAME=torch_nightly
    pip install torch_nightly -f https://download.pytorch.org/whl/nightly/$CUVER/torch_nightly.html
    # CPU/CUDA variants of PyTorch have ABI compatible PyTorch for
    # the CPU only bits.  Therefore, we
    # strip off the local package qualifier, but ONLY if we're
    # doing a CPU build.
    if [[ "$CUVER" == "cpu" ]]; then
        export TORCHVISION_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//' | sed 's/+.\+//')"
    else
        export TORCHVISION_PYTORCH_DEPENDENCY_VERSION="$(pip show torch_nightly | grep ^Version: | sed 's/Version: \+//')"
    fi
    echo "Building against ${TORCHVISION_PYTORCH_DEPENDENCY_VERSION}"

57
58
59
60
61
62
    pip install ninja
    python setup.py clean
    python setup.py bdist_wheel
    mkdir -p $OUT_DIR
    cp dist/*.whl $OUT_DIR/
done