Skip to content

Commit 16ecb3f

Browse files
authored
Fix Windows unittest CI: force CPU-only build (CUDA 13.2 toolkit on runner breaks _portable_lib load) (#20527)
## Summary Fixes the Windows unittest CI breakage introduced by #20440 (`Add CUDA 13.2 support and drop unsupported 12.8/12.9`). `unittest / windows`, `unittest-editable / windows`, and `unittest-release / windows` have been red on `main` since c0643f5 (parent was green). ## Root cause The Windows CI image ships CUDA toolkits on `PATH` (it has both `v13.2` and `v13.0`; `nvcc` resolves to **13.2.78**). `install_executorch` auto-enables the CUDA backend when `install_utils.is_cuda_available()` returns True (`setup.py` ~L882-889), and that check is driven purely by the `nvcc` version being in `SUPPORTED_CUDA_VERSIONS`. - **Before #20440:** `13.2 ∉ SUPPORTED_CUDA_VERSIONS` → `is_cuda_available()` = False → CPU-only build → green. - **After #20440:** adding `(13, 2)` makes `is_cuda_available()` = **True** on the Windows runner → `setup.py` flips `-DEXECUTORCH_BUILD_CUDA=ON`. But the unittest jobs install **CPU** torch, so the CUDA build of `_portable_lib` can't find its CUDA DLLs: ``` ImportError: DLL load failed while importing _portable_lib: The specified module could not be found. ``` That aborts pytest collection (`24 errors during collection`) and fails the job. ## Fix Add a `-cpuOnly` switch to the shared `.ci/scripts/setup-windows.ps1` that forces `-DEXECUTORCH_BUILD_CUDA=OFF` via `CMAKE_ARGS`, and pass it from the CPU unittest workflow (`_unittest.yml`). This restores the pre-#20440 CPU-only behavior for these jobs. The CUDA Windows jobs (`cuda-windows.yml`) call the same script **without** `-cpuOnly`, so they are unaffected and keep building CUDA. ## Note / follow-up The deeper issue is that the auto-detection keys off `nvcc` presence rather than whether the installed torch is actually a CUDA build. A more general fix would be to only enable `EXECUTORCH_BUILD_CUDA` when `torch.version.cuda` is set. Left out here to keep the unblock low-risk; happy to follow up.
1 parent a8cfb75 commit 16ecb3f

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

.ci/scripts/setup-windows.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
param (
2-
[string]$editable = "false"
2+
[string]$editable = "false",
3+
[string]$cpuOnly = "false"
34
)
45

56
conda create --yes --quiet -n et python=3.12
@@ -13,6 +14,16 @@ conda activate et
1314
# Install test dependencies
1415
pip install -r .ci/docker/requirements-ci.txt
1516

17+
# The Windows CI image ships CUDA toolkits on PATH, so install_executorch
18+
# (setup.py) auto-enables EXECUTORCH_BUILD_CUDA whenever the detected nvcc
19+
# version is in SUPPORTED_CUDA_VERSIONS. CPU-only jobs install CPU torch, so a
20+
# CUDA build of _portable_lib then fails to load its CUDA DLLs at import time
21+
# ("DLL load failed while importing _portable_lib"). Force a CPU-only build
22+
# when the caller asks for it.
23+
if ($cpuOnly -eq 'true') {
24+
$env:CMAKE_ARGS = "$env:CMAKE_ARGS -DEXECUTORCH_BUILD_CUDA=OFF"
25+
}
26+
1627
if ($editable -eq 'true') {
1728
install_executorch.bat --editable
1829
} else {

.ci/scripts/wheel/pre_build_script.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,15 @@ if [[ $UNAME_S == *"MINGW"* || $UNAME_S == *"MSYS"* ]]; then
5050
echo "Enabling symlinks on Windows"
5151
git config core.symlinks true
5252
git checkout -f HEAD
53+
54+
# Windows wheels are CPU-only (build-wheels-windows.yml sets
55+
# with-cuda: disabled), but the Windows CI image ships a CUDA toolkit on
56+
# PATH, which makes setup.py auto-enable EXECUTORCH_BUILD_CUDA. That bakes a
57+
# CUDA _portable_lib into the CPU wheel, which then fails its DLL load in the
58+
# smoke test ("DLL load failed while importing _portable_lib"). Force a
59+
# CPU-only build.
60+
export CMAKE_ARGS="${CMAKE_ARGS:-} -DEXECUTORCH_BUILD_CUDA=OFF"
61+
echo "CMAKE_ARGS=${CMAKE_ARGS}" >> "${GITHUB_ENV}"
5362
fi
5463

5564
# Manually install build requirements because `python setup.py bdist_wheel` does

.github/workflows/_unittest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
\$ErrorActionPreference = 'Stop'
7373
\$PSNativeCommandUseErrorActionPreference = \$true
7474
75-
.ci/scripts/setup-windows.ps1 -editable "${{ inputs.editable }}"
75+
.ci/scripts/setup-windows.ps1 -editable "${{ inputs.editable }}" -cpuOnly true
7676
if (\$LASTEXITCODE -ne 0) {
7777
Write-Host "Setup failed. Exit code: \$LASTEXITCODE."
7878
exit \$LASTEXITCODE

0 commit comments

Comments
 (0)