Skip to content

Commit 747da69

Browse files
gasoonjiaclaude
andcommitted
Fix Windows unittest CI: force CPU-only build to avoid CUDA DLL load failure
The Windows CI image ships CUDA toolkits on PATH. After adding (13, 2) to SUPPORTED_CUDA_VERSIONS (#20440), install_executorch's auto-detection (setup.py: is_cuda_available() via nvcc) started returning True on the Windows runner (which has the CUDA 13.2 toolkit), so it flipped EXECUTORCH_BUILD_CUDA=ON. But the unittest jobs install CPU torch, so the resulting CUDA build of _portable_lib fails to load its CUDA DLLs at import time: ImportError: DLL load failed while importing _portable_lib causing all pytest collection to error out (unittest / unittest-editable / unittest-release on windows). Add a -cpuOnly switch to setup-windows.ps1 that forces -DEXECUTORCH_BUILD_CUDA=OFF via CMAKE_ARGS, and pass it from the CPU unittest workflow. The CUDA Windows jobs (cuda-windows.yml) keep the default and are unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 6021a58 commit 747da69

2 files changed

Lines changed: 13 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 {

.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)