Skip to content

Arm64 workflow enablement #8947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .github/workflows/build_wheel_windows_arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Build Windows ARM64 Wheels

on:
pull_request:
push:
branches:
- nightly
- main
- release/*
tags:
# NOTE: Binary build pipelines should only get triggered on release candidate builds
# Release candidate tags look like: v1.11.0-rc1
- v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
generate-matrix:
uses: pytorch/test-infra/.github/workflows/generate_binary_build_matrix.yml@main
with:
package-type: wheel
os: windows-arm64
test-infra-repository: pytorch/test-infra
test-infra-ref: main
with-cuda: disable

build:
needs: generate-matrix
strategy:
fail-fast: false
matrix:
include:
- repository: pytorch/vision
smoke-test-script: test/smoke_test.py
pre-script: packaging/pre_build_script_arm64.sh
package-name: torchvision
architecture: "arm64"
name: ${{ matrix.repository }}
uses: pytorch/test-infra/.github/workflows/build_wheels_windows.yml@main
with:
repository: ${{ matrix.repository }}
ref: ""
test-infra-repository: pytorch/test-infra
test-infra-ref: main
pre-script: ${{ matrix.pre-script }}
build-matrix: ${{ needs.generate-matrix.outputs.matrix }}
package-name: ${{ matrix.package-name }}
smoke-test-script: ${{ matrix.smoke-test-script }}
trigger-event: ${{ github.event_name }}
architecture: ${{ matrix.architecture }}
70 changes: 70 additions & 0 deletions packaging/pre_build_script_arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

echo "Building vision dependencies and wheel started."

# Set environment variables
export SRC_PATH="$GITHUB_WORKSPACE/$SRC_DIR"
export CMAKE_BUILD_TYPE="$BUILD_TYPE"
export VCVARSALL_PATH="$DEPENDENCIES_DIR/VSBuildTools/VC/Auxiliary/Build/vcvarsall.bat"
export CONDA_PREFIX="$DEPENDENCIES_DIR"
export PATH="$PATH:$CONDA_PREFIX/Library/bin"
export DISTUTILS_USE_SDK=1
export TRIPLET_FILE="triplets/arm64-windows.cmake"
export PYTORCH_VERSION="$PYTORCH_VERSION"
export CHANNEL="$CHANNEL"

echo "channel: $CHANNEL"

# Dependencies
mkdir -p "$DOWNLOADS_DIR"
mkdir -p "$DEPENDENCIES_DIR"
echo "*" > "$DOWNLOADS_DIR/.gitignore"
echo "*" > "$DEPENDENCIES_DIR/.gitignore"

# Install vcpkg
cd "$DOWNLOADS_DIR" || exit
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg || exit
./bootstrap-vcpkg.sh

# # Set vcpkg to only build release packages
echo "set(VCPKG_BUILD_TYPE release)" >> "$TRIPLET_FILE"

# Install dependencies using vcpkg
./vcpkg install libjpeg-turbo:arm64-windows --x-install-root="$DEPENDENCIES_DIR"
./vcpkg install libwebp:arm64-windows --x-install-root="$DEPENDENCIES_DIR"
./vcpkg install libpng[tools]:arm64-windows --x-install-root="$DEPENDENCIES_DIR"

# Copy files using cp (replace robocopy)
cp "$DEPENDENCIES_DIR/arm64-windows/lib/libpng16.lib" "$DEPENDENCIES_DIR/arm64-windows/lib/libpng.lib"
cp "$DEPENDENCIES_DIR/arm64-windows/bin/libpng16.dll" "$DEPENDENCIES_DIR/arm64-windows/bin/libpng.dll"
cp "$DEPENDENCIES_DIR/arm64-windows/bin/libpng16.pdb" "$DEPENDENCIES_DIR/arm64-windows/bin/libpng.pdb"
mkdir -p "$DEPENDENCIES_DIR/Library/"
cp -r "$DEPENDENCIES_DIR/arm64-windows/"* "$DEPENDENCIES_DIR/Library/"
cp -r "$DEPENDENCIES_DIR/Library/tools/libpng/"* "$DEPENDENCIES_DIR/Library/bin/"
cp -r "$DEPENDENCIES_DIR/Library/bin/"* "$SRC_PATH/torchvision"

# Source directory
cd "$SRC_PATH" || exit

# Create virtual environment
python -m pip install --upgrade pip
python -m venv .venv
echo "*" > .venv/.gitignore
source .venv/Scripts/activate

# Install dependencies
pip install numpy==2.2.3

if [ "$CHANNEL" = "release" ]; then
echo "Installing latest stable version of PyTorch."
pip3 install torch
elif [ "$CHANNEL" = "test" ]; then
echo "Installing PyTorch version $PYTORCH_VERSION."
pip3 install torch=="$PYTORCH_VERSION"
else
echo "CHANNEL is not set, installing PyTorch from nightly."
pip3 install --pre torch --index-url https://download.pytorch.org/whl/nightly/cpu
fi

echo "Dependencies install finished successfully."