diff --git a/.ci/scripts/setup-windows.ps1 b/.ci/scripts/setup-windows.ps1 index 329e81b3cf0..2cf28e0cdfe 100644 --- a/.ci/scripts/setup-windows.ps1 +++ b/.ci/scripts/setup-windows.ps1 @@ -1,5 +1,6 @@ param ( - [string]$editable = "false" + [string]$editable = "false", + [string]$cpuOnly = "false" ) conda create --yes --quiet -n et python=3.12 @@ -13,6 +14,16 @@ conda activate et # Install test dependencies pip install -r .ci/docker/requirements-ci.txt +# The Windows CI image ships CUDA toolkits on PATH, so install_executorch +# (setup.py) auto-enables EXECUTORCH_BUILD_CUDA whenever the detected nvcc +# version is in SUPPORTED_CUDA_VERSIONS. CPU-only jobs install CPU torch, so a +# CUDA build of _portable_lib then fails to load its CUDA DLLs at import time +# ("DLL load failed while importing _portable_lib"). Force a CPU-only build +# when the caller asks for it. +if ($cpuOnly -eq 'true') { + $env:CMAKE_ARGS = "$env:CMAKE_ARGS -DEXECUTORCH_BUILD_CUDA=OFF" +} + if ($editable -eq 'true') { install_executorch.bat --editable } else { diff --git a/.ci/scripts/wheel/pre_build_script.sh b/.ci/scripts/wheel/pre_build_script.sh index ce3652e51f1..4f3f9a60f9b 100755 --- a/.ci/scripts/wheel/pre_build_script.sh +++ b/.ci/scripts/wheel/pre_build_script.sh @@ -50,6 +50,15 @@ if [[ $UNAME_S == *"MINGW"* || $UNAME_S == *"MSYS"* ]]; then echo "Enabling symlinks on Windows" git config core.symlinks true git checkout -f HEAD + + # Windows wheels are CPU-only (build-wheels-windows.yml sets + # with-cuda: disabled), but the Windows CI image ships a CUDA toolkit on + # PATH, which makes setup.py auto-enable EXECUTORCH_BUILD_CUDA. That bakes a + # CUDA _portable_lib into the CPU wheel, which then fails its DLL load in the + # smoke test ("DLL load failed while importing _portable_lib"). Force a + # CPU-only build. + export CMAKE_ARGS="${CMAKE_ARGS:-} -DEXECUTORCH_BUILD_CUDA=OFF" + echo "CMAKE_ARGS=${CMAKE_ARGS}" >> "${GITHUB_ENV}" fi # Manually install build requirements because `python setup.py bdist_wheel` does diff --git a/.github/workflows/_unittest.yml b/.github/workflows/_unittest.yml index a253857d2c0..e300c1541b8 100644 --- a/.github/workflows/_unittest.yml +++ b/.github/workflows/_unittest.yml @@ -72,7 +72,7 @@ jobs: \$ErrorActionPreference = 'Stop' \$PSNativeCommandUseErrorActionPreference = \$true - .ci/scripts/setup-windows.ps1 -editable "${{ inputs.editable }}" + .ci/scripts/setup-windows.ps1 -editable "${{ inputs.editable }}" -cpuOnly true if (\$LASTEXITCODE -ne 0) { Write-Host "Setup failed. Exit code: \$LASTEXITCODE." exit \$LASTEXITCODE