Skip to content
This repository was archived by the owner on Aug 15, 2025. It is now read-only.

Commit c7564f3

Browse files
iremyuxOzan Aydin
andauthored
Add Windows Arm64 scripts (#2044)
Co-authored-by: Ozan Aydin <[email protected]>
1 parent f8d8cfc commit c7564f3

File tree

9 files changed

+398
-0
lines changed

9 files changed

+398
-0
lines changed

windows/arm64/bootstrap_apl.bat

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@echo off
2+
3+
echo Dependency ARM Performance Libraries (APL) installation started.
4+
5+
:: Pre-check for downloads and dependencies folders
6+
if not exist "%DOWNLOADS_DIR%" mkdir %DOWNLOADS_DIR%
7+
if not exist "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
8+
9+
:: Set download URL for the ARM Performance Libraries (APL)
10+
set DOWNLOAD_URL="https://developer.arm.com/-/cdn-downloads/permalink/Arm-Performance-Libraries/Version_24.10/arm-performance-libraries_24.10_Windows.msi"
11+
set INSTALLER_FILE=%DOWNLOADS_DIR%\arm-performance-libraries.msi
12+
13+
:: Download installer
14+
echo Downloading ARM Performance Libraries (APL)...
15+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
16+
17+
:: Install ARM Performance Libraries (APL)
18+
echo Installing ARM Performance Libraries (APL)...
19+
msiexec /i "%INSTALLER_FILE%" /qn /norestart ACCEPT_EULA=1 INSTALLFOLDER="%DEPENDENCIES_DIR%"
20+
21+
:: Check if installation was successful
22+
if %errorlevel% neq 0 (
23+
echo "Failed to install ARM Performance Libraries (APL) components. (exitcode = %errorlevel%)"
24+
exit /b 1
25+
)
26+
27+
:: Add to environment
28+
echo ARMPL_DIR=%DEPENDENCIES_DIR%\armpl_24.10\>> %GITHUB_ENV%
29+
echo %DEPENDENCIES_DIR%\armpl_24.10\bin\>> %GITHUB_PATH%
30+
31+
echo Dependency ARM Performance Libraries (APL) installation finished.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@echo off
2+
3+
echo Dependency MSVC Build Tools with C++ with ARM64/ARM64EC components installation started.
4+
5+
:: Pre-check for downloads and dependencies folders
6+
if not exist "%DOWNLOADS_DIR%" mkdir "%DOWNLOADS_DIR%"
7+
if not exist "%DEPENDENCIES_DIR%" mkdir "%DEPENDENCIES_DIR%"
8+
9+
:: Set download URL for the Visual Studio Installer
10+
set DOWNLOAD_URL=https://aka.ms/vs/17/release/vs_BuildTools.exe
11+
set INSTALLER_FILE=%DOWNLOADS_DIR%\vs_BuildTools.exe
12+
13+
:: Download installer
14+
echo Downloading Visual Studio Build Tools with C++ installer...
15+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
16+
17+
:: Install the Visual Studio Build Tools with C++ components
18+
echo Installing Visual Studio Build Tools with C++ components...
19+
"%INSTALLER_FILE%" --norestart --nocache --quiet --wait --installPath "%DEPENDENCIES_DIR%\VSBuildTools" ^
20+
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ^
21+
--add Microsoft.VisualStudio.Component.VC.ASAN ^
22+
--add Microsoft.VisualStudio.Component.VC.CMake.Project ^
23+
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
24+
--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^
25+
--add Microsoft.VisualStudio.Component.VC.14.40.17.10.ARM64 ^
26+
--add Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64
27+
28+
29+
:: Check if installation was successful
30+
if %errorlevel% neq 0 (
31+
echo "Failed to install Visual Studio Build Tools with C++ components. (exitcode = %errorlevel%)"
32+
exit /b 1
33+
)
34+
35+
echo Dependency Visual Studio Build Tools with C++ installation finished.

windows/arm64/bootstrap_git.bat

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
:: we need to install newer version of Git manually as "-submodules" function is not supported in the default version of runner.
2+
3+
@echo off
4+
5+
echo Dependency Git installation started.
6+
7+
:: Pre-check for downloads and dependencies folders
8+
if not exist "%DOWNLOADS_DIR%" mkdir %DOWNLOADS_DIR%
9+
if not exist "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
10+
11+
:: Set download URL for the Git
12+
set DOWNLOAD_URL="https://github.com/git-for-windows/git/releases/download/v2.46.0.windows.1/Git-2.46.0-64-bit.exe"
13+
set INSTALLER_FILE=%DOWNLOADS_DIR%\Git-2.46.0-64-bit.exe
14+
15+
:: Download installer
16+
echo Downloading Git...
17+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
18+
19+
:: Install Git
20+
echo Installing Git...
21+
"%INSTALLER_FILE%" /VERYSILENT /DIR="%DEPENDENCIES_DIR%\git"
22+
23+
dir %DEPENDENCIES_DIR%\git
24+
25+
:: Check if installation was successful
26+
if %errorlevel% neq 0 (
27+
echo "Failed to install Git. (exitcode = %errorlevel%)"
28+
exit /b 1
29+
)
30+
31+
:: Enable long paths
32+
call "%DEPENDENCIES_DIR%\git\cmd\git.exe" config --system core.longpaths true
33+
34+
:: Add to PATH
35+
echo %DEPENDENCIES_DIR%\git\cmd\;%DEPENDENCIES_DIR%\git\bin\>> %GITHUB_PATH%
36+
37+
echo Dependency Git installation finished.

windows/arm64/bootstrap_python.bat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
@echo off
3+
4+
echo Dependency Python installation started.
5+
6+
:: Pre-check for downloads and dependencies folders
7+
if not exist "%DOWNLOADS_DIR%" mkdir %DOWNLOADS_DIR%
8+
if not exist "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
9+
10+
if "%PYTHON_VERSION%"=="Python312" (
11+
echo Python version is set to Python312
12+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.12.7/python-3.12.7-arm64.exe"
13+
) else if "%PYTHON_VERSION%"=="Python311" (
14+
echo Python version is set to Python311
15+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.11.9/python-3.11.9-arm64.exe"
16+
) else (
17+
echo PYTHON_VERSION not defined, Python version is set to Python312
18+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.12.7/python-3.12.7-arm64.exe"
19+
)
20+
21+
set INSTALLER_FILE=%DOWNLOADS_DIR%\python-installer.exe
22+
23+
:: Download installer
24+
echo Downloading Python...
25+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
26+
27+
:: Install Python
28+
echo Installing Python...
29+
"%INSTALLER_FILE%" /quiet Include_debug=1 TargetDir="%DEPENDENCIES_DIR%\Python"
30+
31+
:: Check if installation was successful
32+
if %errorlevel% neq 0 (
33+
echo "Failed to install Git. (exitcode = %errorlevel%)"
34+
exit /b 1
35+
)
36+
37+
:: Add to PATH
38+
echo %DEPENDENCIES_DIR%\Python\>> %GITHUB_PATH%
39+
echo %DEPENDENCIES_DIR%\Python\scripts\>> %GITHUB_PATH%
40+
echo %DEPENDENCIES_DIR%\Python\libs\>> %GITHUB_PATH%
41+
42+
echo Dependency Python installation finished.

windows/arm64/bootstrap_rust.bat

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
@echo off
3+
4+
echo Dependency Rust installation started.
5+
6+
:: Pre-check for downloads and dependencies folders
7+
if not exist "%DOWNLOADS_DIR%" mkdir %DOWNLOADS_DIR%
8+
if not exist "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
9+
10+
set DOWNLOAD_URL="https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe"
11+
set INSTALLER_FILE=%DOWNLOADS_DIR%\rustup-init.exe
12+
set RUSTUP_HOME=%DEPENDENCIES_DIR%\rust
13+
set CARGO_HOME=%DEPENDENCIES_DIR%\cargo
14+
15+
:: Download installer
16+
echo Downloading Rust...
17+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
18+
19+
:: Install APL
20+
echo Installing Rust...
21+
"%INSTALLER_FILE%" -q -y --default-host aarch64-pc-windows-msvc --default-toolchain stable --profile default
22+
23+
:: Check if installation was successful
24+
if %errorlevel% neq 0 (
25+
echo "Failed to install Rust. (exitcode = %errorlevel%)"
26+
exit /b 1
27+
)
28+
29+
:: Add to PATH
30+
echo %DEPENDENCIES_DIR%\cargo\bin\>> %GITHUB_PATH%
31+
echo RUSTUP_HOME=%DEPENDENCIES_DIR%\rust>> %GITHUB_ENV%
32+
echo CARGO_HOME=%DEPENDENCIES_DIR%\cargo>> %GITHUB_ENV%
33+
34+
echo Dependency Rust installation finished.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@echo off
2+
3+
echo Dependency sccache installation started.
4+
5+
:: Pre-check for downloads and dependencies folders
6+
if not exist "%DOWNLOADS_DIR%" mkdir %DOWNLOADS_DIR%
7+
if not exist "%DEPENDENCIES_DIR%" mkdir %DEPENDENCIES_DIR%
8+
9+
:: Set download URL for the sccache
10+
set DOWNLOAD_URL="https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-pc-windows-msvc.zip"
11+
set INSTALLER_FILE=%DOWNLOADS_DIR%\sccache.zip
12+
13+
:: Download installer
14+
echo Downloading sccache.zip...
15+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
16+
17+
:: Install sccache
18+
echo Extracting sccache.zip...
19+
tar -xf "%INSTALLER_FILE%" -C %DEPENDENCIES_DIR%
20+
cd %DEPENDENCIES_DIR%
21+
ren sccache-v0.8.1-x86_64-pc-windows-msvc sccache
22+
cd ..
23+
24+
:: Check if installation was successful
25+
if %errorlevel% neq 0 (
26+
echo "Failed to install sccache. (exitcode = %errorlevel%)"
27+
exit /b 1
28+
)
29+
30+
:: Add to PATH
31+
echo %DEPENDENCIES_DIR%\sccache\>> %GITHUB_PATH%
32+
33+
echo Dependency sccache installation finished.

windows/arm64/build_libtorch.bat

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
@echo on
2+
3+
:: Set the CMAKE_BUILD_TYPE
4+
set "CMAKE_BUILD_TYPE=%BUILD_TYPE%"
5+
6+
:: activate visual studio
7+
call "%DEPENDENCIES_DIR%\VSBuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64 -vcvars_ver=%MSVC_VERSION%
8+
where cl.exe
9+
10+
:: change to source directory
11+
cd %PYTORCH_ROOT%
12+
13+
:: create virtual environment
14+
python -m venv .venv
15+
echo * > .venv\.gitignore
16+
call .\.venv\Scripts\activate
17+
where python
18+
19+
:: python install dependencies
20+
python -m pip install --upgrade pip
21+
pip install -r requirements.txt
22+
23+
:: start sccache server and reset sccache stats
24+
sccache --start-server
25+
sccache --zero-stats
26+
sccache --show-stats
27+
28+
:: Prepare the environment
29+
mkdir libtorch
30+
mkdir libtorch\bin
31+
mkdir libtorch\cmake
32+
mkdir libtorch\include
33+
mkdir libtorch\lib
34+
mkdir libtorch\share
35+
mkdir libtorch\test
36+
37+
:: Call LibTorch build script
38+
python ./tools/build_libtorch.py
39+
40+
:: Check if there is an error
41+
IF ERRORLEVEL 1 exit /b 1
42+
IF NOT ERRORLEVEL 0 exit /b 1
43+
44+
:: Move the files to the correct location
45+
move /Y torch\bin\*.* libtorch\bin\
46+
move /Y torch\cmake\*.* libtorch\cmake\
47+
robocopy /move /e torch\include\ libtorch\include\
48+
move /Y torch\lib\*.* libtorch\lib\
49+
robocopy /move /e torch\share\ libtorch\share\
50+
move /Y torch\test\*.* libtorch\test\
51+
move /Y libtorch\bin\*.dll libtorch\lib\
52+
53+
:: Set version
54+
echo %PYTORCH_BUILD_VERSION% > libtorch\build-version
55+
git rev-parse HEAD > libtorch\build-hash
56+
57+
:: Set LIBTORCH_PREFIX
58+
IF "%DEBUG%" == "" (
59+
set LIBTORCH_PREFIX=libtorch-win-arm64-shared-with-deps
60+
) ELSE (
61+
set LIBTORCH_PREFIX=libtorch-win-arm64-shared-with-deps-debug
62+
)
63+
64+
:: Create output
65+
C:\Windows\System32\tar.exe -cvaf %LIBTORCH_PREFIX%-%PYTORCH_BUILD_VERSION%.zip -C libtorch *
66+
67+
:: Copy output to target directory
68+
if not exist ..\output mkdir ..\output
69+
copy /Y "%LIBTORCH_PREFIX%-%PYTORCH_BUILD_VERSION%.zip" "%PYTORCH_FINAL_PACKAGE_DIR%\"
70+
copy /Y "%LIBTORCH_PREFIX%-%PYTORCH_BUILD_VERSION%.zip" "%PYTORCH_FINAL_PACKAGE_DIR%\%LIBTORCH_PREFIX%-latest.zip"
71+
72+
:: Cleanup raw data to save space
73+
rmdir /s /q libtorch

windows/arm64/build_pytorch.bat

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
@echo on
2+
3+
:: environment variables
4+
set BLAS=APL
5+
set USE_LAPACK=1
6+
set CMAKE_BUILD_TYPE=%BUILD_TYPE%
7+
set CMAKE_C_COMPILER_LAUNCHER=sccache
8+
set CMAKE_CXX_COMPILER_LAUNCHER=sccache
9+
if defined PYTORCH_BUILD_VERSION (
10+
set PYTORCH_BUILD_VERSION=%PYTORCH_BUILD_VERSION%
11+
set PYTORCH_BUILD_NUMBER=1
12+
)
13+
14+
:: activate visual studio
15+
call "%DEPENDENCIES_DIR%\VSBuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64 -vcvars_ver=%MSVC_VERSION%
16+
where cl.exe
17+
18+
:: change to source directory
19+
cd %PYTORCH_ROOT%
20+
21+
:: create virtual environment
22+
python -m venv .venv
23+
echo * > .venv\.gitignore
24+
call .\.venv\Scripts\activate
25+
where python
26+
27+
:: python install dependencies
28+
python -m pip install --upgrade pip
29+
pip install wheel
30+
pip install -r requirements.txt
31+
32+
:: start sccache server and reset sccache stats
33+
sccache --start-server
34+
sccache --zero-stats
35+
sccache --show-stats
36+
37+
:: Call PyTorch build script
38+
python setup.py bdist_wheel -d "%PYTORCH_FINAL_PACKAGE_DIR%"
39+
40+
:: show sccache stats
41+
sccache --show-stats
42+
43+
:: Check if installation was successful
44+
if %errorlevel% neq 0 (
45+
echo "Failed on build_pytorch. (exitcode = %errorlevel%)"
46+
exit /b 1
47+
)

0 commit comments

Comments
 (0)