Skip to content

Commit bfafcdc

Browse files
committed
Build Windows ARM64 binaries cross-compiled on x64
1 parent 1ceb949 commit bfafcdc

File tree

4 files changed

+38
-16
lines changed

4 files changed

+38
-16
lines changed

windows/build_pytorch.bat

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@echo off
2-
31
:: This script parses args, installs required libraries (miniconda, MKL,
42
:: Magma), and then delegates to cpu.bat, cuda80.bat, etc.
53

windows/cpu.bat

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@echo off
2-
31
set MODULE_NAME=pytorch
42

53
IF NOT EXIST "setup.py" IF NOT EXIST "%MODULE_NAME%" (

windows/internal/setup.bat

+23-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,39 @@
1-
@echo off
1+
@echo on
22

33
echo The flags after configuring:
44
echo USE_CUDA=%USE_CUDA%
55
echo CMAKE_GENERATOR=%CMAKE_GENERATOR%
6+
echo CROSS_COMPILE_ARM64=%CROSS_COMPILE_ARM64%
7+
68
if "%USE_CUDA%"=="" echo CUDA_PATH=%CUDA_PATH%
79
if NOT "%CC%"=="" echo CC=%CC%
810
if NOT "%CXX%"=="" echo CXX=%CXX%
911
if NOT "%DISTUTILS_USE_SDK%"=="" echo DISTUTILS_USE_SDK=%DISTUTILS_USE_SDK%
1012

1113
set SRC_DIR=%~dp0\..
1214

15+
set
16+
17+
if "%CROSS_COMPILE_ARM64%" == "" (
18+
set VSDEVCMD_ARCH=x64
19+
) else (
20+
set VSDEVCMD_ARCH=x64_arm64
21+
set CMAKE_TOOLCHAIN_FILE=cmake\Toolchains\msvc2022-x64-arm64.cmake
22+
set USE_HOST_PROTOC=1
23+
set PROTOC=%CONDA_HOME%\Library\bin\protoc.exe
24+
)
25+
26+
if EXIST %PROTOC% (
27+
echo "%PROTOC% is installed"
28+
) else (
29+
echo "%PROTOC% is not installed"
30+
call protoc.exe
31+
)
32+
1333
IF "%VSDEVCMD_ARGS%" == "" (
14-
call "%VS15VCVARSALL%" x64
34+
call "%VS15VCVARSALL%" %VSDEVCMD_ARCH%
1535
) ELSE (
16-
call "%VS15VCVARSALL%" x64 %VSDEVCMD_ARGS%
36+
call "%VS15VCVARSALL%" %VSDEVCMD_ARCH% %VSDEVCMD_ARGS%
1737
)
1838

1939
pushd %SRC_DIR%

windows/internal/vs2022_install.ps1

+15-9
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@
44
# 17.4.3 BuildTools
55
$VS_DOWNLOAD_LINK = "https://download.visualstudio.microsoft.com/download/pr/8f480125-28b8-4a2c-847c-c2b02a8cdd1b/64be21d4ada005d7d07896ed0b004c322409bd04d6e8eba4c03c9fa39c928e7a/vs_BuildTools.exe"
66
$COLLECT_DOWNLOAD_LINK = "https://aka.ms/vscollect.exe"
7-
$VS_INSTALL_ARGS = @("--nocache","--quiet","--wait", "--add Microsoft.VisualStudio.Workload.VCTools",
8-
"--add Microsoft.Component.MSBuild",
9-
"--add Microsoft.VisualStudio.Component.Roslyn.Compiler",
10-
"--add Microsoft.VisualStudio.Component.TextTemplating",
11-
"--add Microsoft.VisualStudio.Component.VC.CoreIde",
12-
"--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
13-
"--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
14-
"--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
15-
"--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Win81")
7+
$VS_INSTALL_ARGS = @(
8+
"--nocache",
9+
"--quiet",
10+
"--wait",
11+
"--add Microsoft.VisualStudio.Workload.VCTools",
12+
"--add Microsoft.Component.MSBuild",
13+
"--add Microsoft.VisualStudio.Component.Roslyn.Compiler",
14+
"--add Microsoft.VisualStudio.Component.TextTemplating",
15+
"--add Microsoft.VisualStudio.Component.VC.CoreIde",
16+
"--add Microsoft.VisualStudio.Component.VC.Redist.14.Latest",
17+
"--add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core",
18+
"--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64",
19+
"--add Microsoft.VisualStudio.Component.VC.Tools.ARM64",
20+
"--add Microsoft.VisualStudio.Component.Windows10SDK.20348"
21+
)
1622

1723
curl.exe --retry 3 -kL $VS_DOWNLOAD_LINK --output vs_installer.exe
1824
if ($LASTEXITCODE -ne 0) {

0 commit comments

Comments
 (0)