|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +echo "Building vision dependencies and wheel started." |
| 4 | + |
| 5 | +# Set environment variables |
| 6 | +export SRC_PATH="$GITHUB_WORKSPACE/$SRC_DIR" |
| 7 | +export CMAKE_BUILD_TYPE="$BUILD_TYPE" |
| 8 | +export VCVARSALL_PATH="$DEPENDENCIES_DIR/VSBuildTools/VC/Auxiliary/Build/vcvarsall.bat" |
| 9 | +export CONDA_PREFIX="$DEPENDENCIES_DIR" |
| 10 | +export PATH="$PATH:$CONDA_PREFIX/Library/bin" |
| 11 | +export DISTUTILS_USE_SDK=1 |
| 12 | +export TRIPLET_FILE="triplets/arm64-windows.cmake" |
| 13 | +export PYTORCH_VERSION="$PYTORCH_VERSION" |
| 14 | +export CHANNEL="$CHANNEL" |
| 15 | + |
| 16 | +# Dependencies |
| 17 | +mkdir -p "$DOWNLOADS_DIR" |
| 18 | +mkdir -p "$DEPENDENCIES_DIR" |
| 19 | +echo "*" > "$DOWNLOADS_DIR/.gitignore" |
| 20 | +echo "*" > "$DEPENDENCIES_DIR/.gitignore" |
| 21 | + |
| 22 | +# Install vcpkg |
| 23 | +cd "$DOWNLOADS_DIR" || exit |
| 24 | +git clone https://github.com/microsoft/vcpkg.git |
| 25 | +cd vcpkg || exit |
| 26 | +./bootstrap-vcpkg.sh |
| 27 | + |
| 28 | +# Set vcpkg to only build release packages |
| 29 | +echo "set(VCPKG_BUILD_TYPE release)" >> "$TRIPLET_FILE" |
| 30 | + |
| 31 | +# Install dependencies using vcpkg |
| 32 | +./vcpkg install libjpeg-turbo:arm64-windows --x-install-root="$DEPENDENCIES_DIR" |
| 33 | +./vcpkg install libwebp:arm64-windows --x-install-root="$DEPENDENCIES_DIR" |
| 34 | +./vcpkg install libpng[tools]:arm64-windows --x-install-root="$DEPENDENCIES_DIR" |
| 35 | + |
| 36 | +# Copy files using cp |
| 37 | +cp "$DEPENDENCIES_DIR/arm64-windows/lib/libpng16.lib" "$DEPENDENCIES_DIR/arm64-windows/lib/libpng.lib" |
| 38 | +cp "$DEPENDENCIES_DIR/arm64-windows/bin/libpng16.dll" "$DEPENDENCIES_DIR/arm64-windows/bin/libpng.dll" |
| 39 | +cp "$DEPENDENCIES_DIR/arm64-windows/bin/libpng16.pdb" "$DEPENDENCIES_DIR/arm64-windows/bin/libpng.pdb" |
| 40 | +mkdir -p "$DEPENDENCIES_DIR/Library/" |
| 41 | +cp -r "$DEPENDENCIES_DIR/arm64-windows/"* "$DEPENDENCIES_DIR/Library/" |
| 42 | +cp -r "$DEPENDENCIES_DIR/Library/tools/libpng/"* "$DEPENDENCIES_DIR/Library/bin/" |
| 43 | +cp -r "$DEPENDENCIES_DIR/Library/bin/"* "$SRC_PATH/torchvision" |
| 44 | + |
| 45 | +# Source directory |
| 46 | +cd "$SRC_PATH" || exit |
| 47 | + |
| 48 | +# Create virtual environment |
| 49 | +python -m pip install --upgrade pip |
| 50 | +python -m venv .venv |
| 51 | +echo "*" > .venv/.gitignore |
| 52 | +source .venv/Scripts/activate |
| 53 | + |
| 54 | +# Install dependencies |
| 55 | +pip install numpy==2.2.3 |
| 56 | + |
| 57 | +if [ "$CHANNEL" = "release" ]; then |
| 58 | + echo "Installing latest stable version of PyTorch." |
| 59 | + # TODO: update when arm64 torch available on pypi |
| 60 | + pip3 install --pre torch --index-url https://download.pytorch.org/whl/torch/ |
| 61 | +elif [ "$CHANNEL" = "test" ]; then |
| 62 | + echo "Installing PyTorch version $PYTORCH_VERSION." |
| 63 | + pip3 install --pre torch=="$PYTORCH_VERSION" --index-url https://download.pytorch.org/whl/test |
| 64 | +else |
| 65 | + echo "CHANNEL is not set, installing PyTorch from nightly." |
| 66 | + pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu |
| 67 | +fi |
| 68 | + |
| 69 | +echo "Dependencies install finished successfully." |
0 commit comments