Skip to content

Enable Windows on ARM CUDA target - #799

Open
mfuntowicz wants to merge 1 commit into
mainfrom
feat/windows-on-arm-backend-cuda
Open

Enable Windows on ARM CUDA target#799
mfuntowicz wants to merge 1 commit into
mainfrom
feat/windows-on-arm-backend-cuda

Conversation

@mfuntowicz

@mfuntowicz mfuntowicz commented Aug 31, 2026

Copy link
Copy Markdown
Member

Summary

This PR enables building the CUDA backend for Windows on Arm by adding a target architecture option to the Windows builder, plus a small CMake fix required by newer CUDA toolkits.
Previously, builder.ps1 always derived the build architecture from the host process architecture, making it impossible to cross-compile ARM64 binaries from an x64 machine. This PR introduces an explicit -TargetArch parameter so the CUDA backend can now be built natively on ARM64 machines or cross-compiled from x64 hosts.

Changes

  • New -TargetArch parameter (x64 | ARM64), defaulting to the host architecture — preserving existing behavior.
  • Initialize-VSEnvironment selects the correct vcvarsall.bat argument for the host/target combination (arm64, x64_arm64, arm64_x64), enabling cross-compilation.
  • Get-CMakeConfigureArgs passes the target architecture to the Visual Studio generator (-A ARM64 / -A x64) instead of hardcoding the detected host platform.
  • Informative message when targeting Windows ARM64 with CUDA (requires CUDA 13.0+ for Windows ARM64 support), and a warning when ARM64 is requested with a non-CUDA backend (only CUDA officially supports Windows ARM64).
    kernel-builder/src/pyproject/templates/torch/preamble.cmake
  • When building with MSVC, add -Xcompiler=/Zc:preprocessor to the nvcc flags. CCCL shipped with CUDA 13+ hard-errors when nvcc uses MSVC's traditional (non-conforming) preprocessor as the host preprocessor, which is required for the ARM64 CUDA build to succeed.

Usage

Native ARM64 build on an ARM64 machine

.\builder.ps1 -SourceFolder ./examples/relu -Backend cuda -TargetArch ARM64 -ArchList "12.1" -Build

Cross-compile from an x64 host

.\builder.ps1 -SourceFolder ./examples/relu -Backend cuda -TargetArch ARM64 -ArchList "12.1" -Build

Notes

  • CUDA support for Windows ARM64 requires CUDA toolkit 13.0 or newer.
  • x64-only workflows are unaffected: without -TargetArch, the script behaves exactly as before.

@mfuntowicz
mfuntowicz requested a review from danieldk August 31, 2026 13:45
@mfuntowicz
mfuntowicz force-pushed the feat/windows-on-arm-backend-cuda branch from 2741398 to e06c763 Compare August 31, 2026 13:48
@mfuntowicz

Copy link
Copy Markdown
Member Author

Example output:

(kernels) PS C:\Users\momo-\workspace\kernels> .\nix-builder\scripts\windows\builder.ps1 .\examples\kernels\relu\ -TargetArch ARM64 -Backend CUDA -Build -Force
[*] Found kernel-builder at: C:\Users\momo-\workspace\kernels\nix-builder\scripts\windows\..\..\..\target\debug\kernel-builder.exe
[*] Generating CUDA backend...
[*] Executing: C:\Users\momo-\workspace\kernels\nix-builder\scripts\windows\..\..\..\target\debug\kernel-builder.exe create-pyproject C:\Users\momo-\workspace\kernels\examples\kernels\relu\ --force
[+] Generation completed successfully!
[*] Targeting Windows ARM64 with CUDA backend - requires a CUDA toolkit with Windows ARM64 support (CUDA 13.0+)
[*] Building project with CMake...
[*] Configuration: Release
[*] Target architecture: ARM64
[*] Initializing Visual Studio environment...
[*] Visual Studio environment already initialized
[*] Configuring CMake project...
[*] Target architecture: ARM64, using Visual Studio platform: ARM64
[*] Using Python from environment: C:\Users\momo-\workspace\kernels\.venv/Scripts\python.exe
[*] Detected PyTorch version: 2.15.0.dev20260831+cu134
CMake Warning (dev) at CMakeLists.txt:17 (project):
  project() called with 'LANGUAGES' as first argument.  The first parameter
  should be the project name, not a keyword argument.  See the
  cmake-commands(7) manual for correct usage of the project() command.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Selecting Windows SDK version 10.0.26100.0 to target Windows 10.0.28000.
-- FetchContent base directory: C:/Users/momo-/workspace/kernels/examples/kernels/relu/build/_deps
-- Found Python3: C:\Users\momo-\workspace\kernels\.venv/Scripts\python.exe (found version "3.13.15") found components: Development Development.SABIModule Interpreter Development.Module Development.Embed
-- Using backend: cuda, GPU language: CUDA
-- PyTorch: CUDA detected: 13.4
-- PyTorch: CUDA nvcc is: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.4/bin/nvcc.exe
-- PyTorch: CUDA toolkit directory: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.4
-- PyTorch: Header version is: 13.4
-- C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v13.4/lib/x64/nvrtc.lib shorthash is 629d40cf
-- USE_CUDNN is set to 0. Compiling without cuDNN support
-- USE_CUSPARSELT is set to 0. Compiling without cuSPARSELt support
-- USE_CUDSS is set to 0. Compiling without cuDSS support
-- USE_CUFILE is set to 0. Compiling without cuFile support
-- Autodetected CUDA architecture(s):  12.1(2.0)
-- Added CUDA NVCC flags for: -gencode;arch=compute_20,code=sm_121
CMake Warning at C:/Users/momo-/workspace/kernels/.venv/Lib/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:22 (message):
  library kineto not found.
Call Stack (most recent call first):
  C:/Users/momo-/workspace/kernels/.venv/Lib/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:119 (append_torchlib_if_found)
  CMakeLists.txt:55 (find_package)


-- CUDA base archs used for intersection with kernel archs: 7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0;12.1
-- Default CUDA kernel architectures: 7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0;12.1+PTX
-- Generated build name: torch215-cu134-aarch64-windows
-- CUDA kernel: relu, capabilities: 7.5;8.0;8.6;8.7;8.9;9.0;10.0;11.0;12.0;12.1+PTX
-- Using PACKAGE_NAME: relu
-- GPU archs: 10.0;11.0;12.0;12.1+PTX;7.5;8.0;8.6;8.7;8.9;9.0
-- Added install rules for _relu_cuda_54964b2_dirty -> torch215-cu134-aarch64-windows
-- Added install rules for _relu_cuda_54964b2_dirty -> build/torch215-cu134-aarch64-windows
-- Configuring done (10.5s)
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:

    Python_EXECUTABLE


-- Build files have been written to: C:/Users/momo-/workspace/kernels/examples/kernels/relu/build
[*] Building project...
MSBuild version 18.9.1+a81b43525 for .NET Framework

  torch_binding.cpp
[...]
[+] Build completed successfully!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant