Skip to content

Commit 527101f

Browse files
iremyuxOzan Aydin
authored andcommitted
Move Windows arm64 scripts from pytorch/builder (pytorch#144317)
This PR moves the Windows Arm64 scripts from the builder repository to the main repository. The corresponding PR to pytorch/builder that removes them is here : pytorch/builder#2058 Pull Request resolved: pytorch#144317 Approved by: https://github.com/Skylion007, https://github.com/seemethere Co-authored-by: Ozan Aydin <[email protected]>
1 parent 66bf7da commit 527101f

14 files changed

+605
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
r"""
2+
It's used to check basic rnn features with cpu-only.
3+
For example, it would throw exception if some components are missing
4+
"""
5+
6+
import torch
7+
import torch.nn as nn
8+
import torch.nn.functional as F
9+
import torch.optim as optim
10+
11+
12+
class SimpleCNN(nn.Module):
13+
def __init__(self):
14+
super().__init__()
15+
self.conv = nn.Conv2d(1, 1, 3)
16+
self.pool = nn.MaxPool2d(2, 2)
17+
18+
def forward(self, inputs):
19+
output = self.pool(F.relu(self.conv(inputs)))
20+
output = output.view(1)
21+
return output
22+
23+
24+
try:
25+
# Mock one infer
26+
net = SimpleCNN()
27+
net_inputs = torch.rand((1, 1, 5, 5))
28+
outputs = net(net_inputs)
29+
print(outputs)
30+
31+
criterion = nn.MSELoss()
32+
optimizer = optim.SGD(net.parameters(), lr=0.001, momentum=0.1)
33+
34+
# Mock one step training
35+
label = torch.full((1,), 1.0, dtype=torch.float)
36+
loss = criterion(outputs, label)
37+
loss.backward()
38+
optimizer.step()
39+
40+
except Exception as e:
41+
print(f"An error occurred: {e}")
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
r"""
2+
It's used to check basic rnn features with cpu-only.
3+
For example, it would throw exception if missing some components are missing
4+
"""
5+
6+
import torch
7+
import torch.nn as nn
8+
9+
10+
rnn = nn.RNN(10, 20, 2)
11+
inputs = torch.randn(5, 3, 10)
12+
h0 = torch.randn(2, 3, 20)
13+
output, hn = rnn(inputs, h0)
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: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
echo Installing MSVC %MSVC_VERSION%
20+
if "%MSVC_VERSION%" == "latest" (
21+
"%INSTALLER_FILE%" --norestart --nocache --quiet --wait --installPath "%DEPENDENCIES_DIR%\VSBuildTools" ^
22+
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ^
23+
--add Microsoft.VisualStudio.Component.VC.ASAN ^
24+
--add Microsoft.VisualStudio.Component.VC.CMake.Project ^
25+
--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ^
26+
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64
27+
) else if "%MSVC_VERSION%" == "14.40" (
28+
"%INSTALLER_FILE%" --norestart --nocache --quiet --wait --installPath "%DEPENDENCIES_DIR%\VSBuildTools" ^
29+
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ^
30+
--add Microsoft.VisualStudio.Component.VC.ASAN ^
31+
--add Microsoft.VisualStudio.Component.VC.CMake.Project ^
32+
--add Microsoft.VisualStudio.Component.VC.14.40.17.10.ARM64 ^
33+
--add Microsoft.VisualStudio.Component.VC.14.40.17.10.x86.x64
34+
) else if "%MSVC_VERSION%" == "14.36" (
35+
"%INSTALLER_FILE%" --norestart --nocache --quiet --wait --installPath "%DEPENDENCIES_DIR%\VSBuildTools" ^
36+
--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ^
37+
--add Microsoft.VisualStudio.Component.VC.ASAN ^
38+
--add Microsoft.VisualStudio.Component.VC.CMake.Project ^
39+
--add Microsoft.VisualStudio.Component.VC.14.36.17.6.ARM64 ^
40+
--add Microsoft.VisualStudio.Component.VC.14.36.17.6.x86.x64
41+
)
42+
43+
:: Check if installation was successful
44+
if %errorlevel% neq 0 (
45+
echo "Failed to install Visual Studio Build Tools with C++ components. (exitcode = %errorlevel%)"
46+
exit /b 1
47+
)
48+
49+
echo Dependency Visual Studio Build Tools with C++ installation finished.
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.
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 libuv 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+
:: activate visual studio
10+
call "%DEPENDENCIES_DIR%\VSBuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64
11+
where cl.exe
12+
13+
cd %DEPENDENCIES_DIR%
14+
git clone https://github.com/libuv/libuv.git -b v1.39.0
15+
16+
echo Configuring libuv...
17+
mkdir libuv\build
18+
cd libuv\build
19+
cmake .. -DBUILD_TESTING=OFF
20+
21+
echo Building libuv...
22+
cmake --build . --config Release
23+
24+
echo Installing libuv...
25+
cmake --install . --prefix ../install
26+
27+
:: Check if installation was successful
28+
if %errorlevel% neq 0 (
29+
echo "Failed to install libuv. (exitcode = %errorlevel%)"
30+
exit /b 1
31+
)
32+
33+
echo Dependency libuv installation finished.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
@echo off
2+
3+
echo Dependency OpenBLAS 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+
:: activate visual studio
10+
call "%DEPENDENCIES_DIR%\VSBuildTools\VC\Auxiliary\Build\vcvarsall.bat" arm64
11+
where cl.exe
12+
13+
:: Clone OpenBLAS
14+
cd %DEPENDENCIES_DIR%
15+
git clone https://github.com/OpenMathLib/OpenBLAS.git -b v0.3.29
16+
17+
echo Configuring OpenBLAS...
18+
mkdir OpenBLAS\build
19+
cd OpenBLAS\build
20+
cmake .. -G Ninja ^
21+
-DBUILD_TESTING=0 ^
22+
-DBUILD_BENCHMARKS=0 ^
23+
-DC_LAPACK=1 ^
24+
-DNOFORTRAN=1 ^
25+
-DDYNAMIC_ARCH=0 ^
26+
-DARCH=arm64 ^
27+
-DBINARY=64 ^
28+
-DTARGET=GENERIC ^
29+
-DUSE_OPENMP=1 ^
30+
-DCMAKE_SYSTEM_PROCESSOR=ARM64 ^
31+
-DCMAKE_SYSTEM_NAME=Windows ^
32+
-DCMAKE_BUILD_TYPE=Release
33+
34+
echo Building OpenBLAS...
35+
cmake --build . --config Release
36+
37+
echo Installing OpenBLAS...
38+
cmake --install . --prefix ../install
39+
40+
:: Check if installation was successful
41+
if %errorlevel% neq 0 (
42+
echo "Failed to install OpenBLAS. (exitcode = %errorlevel%)"
43+
exit /b 1
44+
)
45+
46+
echo Dependency OpenBLAS installation finished.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
@echo off
2+
3+
echo Dependency Python 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+
if "%PYTHON_VERSION%"=="Python312" (
10+
echo Python version is set to Python312
11+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.12.7/python-3.12.7-arm64.exe"
12+
) else if "%PYTHON_VERSION%"=="Python311" (
13+
echo Python version is set to Python311
14+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.11.9/python-3.11.9-arm64.exe"
15+
) else (
16+
echo PYTHON_VERSION not defined, Python version is set to Python312
17+
set DOWNLOAD_URL="https://www.python.org/ftp/python/3.12.7/python-3.12.7-arm64.exe"
18+
)
19+
20+
set INSTALLER_FILE=%DOWNLOADS_DIR%\python-installer.exe
21+
22+
:: Download installer
23+
echo Downloading Python...
24+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
25+
26+
:: Install Python
27+
echo Installing Python...
28+
"%INSTALLER_FILE%" /quiet Include_debug=1 TargetDir="%DEPENDENCIES_DIR%\Python"
29+
30+
:: Check if installation was successful
31+
if %errorlevel% neq 0 (
32+
echo "Failed to install Python. (exitcode = %errorlevel%)"
33+
exit /b 1
34+
)
35+
36+
:: Add to PATH
37+
echo %DEPENDENCIES_DIR%\Python\>> %GITHUB_PATH%
38+
echo %DEPENDENCIES_DIR%\Python\scripts\>> %GITHUB_PATH%
39+
echo %DEPENDENCIES_DIR%\Python\libs\>> %GITHUB_PATH%
40+
41+
echo Dependency Python 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 Rust 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="https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe"
10+
set INSTALLER_FILE=%DOWNLOADS_DIR%\rustup-init.exe
11+
set RUSTUP_HOME=%DEPENDENCIES_DIR%\rust
12+
set CARGO_HOME=%DEPENDENCIES_DIR%\cargo
13+
14+
:: Download installer
15+
echo Downloading Rust...
16+
curl -L -o "%INSTALLER_FILE%" %DOWNLOAD_URL%
17+
18+
:: Install APL
19+
echo Installing Rust...
20+
"%INSTALLER_FILE%" -q -y --default-host aarch64-pc-windows-msvc --default-toolchain stable --profile default
21+
22+
:: Check if installation was successful
23+
if %errorlevel% neq 0 (
24+
echo "Failed to install Rust. (exitcode = %errorlevel%)"
25+
exit /b 1
26+
)
27+
28+
:: Add to PATH
29+
echo %DEPENDENCIES_DIR%\cargo\bin\>> %GITHUB_PATH%
30+
echo RUSTUP_HOME=%DEPENDENCIES_DIR%\rust>> %GITHUB_ENV%
31+
echo CARGO_HOME=%DEPENDENCIES_DIR%\cargo>> %GITHUB_ENV%
32+
33+
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.

0 commit comments

Comments
 (0)