fix(ai-bundles): stop CPU onnxruntime from clobbering onnxruntime-gpu (#544)

Both PyPI onnxruntime flavors unpack into the same site-packages directory, so a bundle carrying the CPU build (transcription, via faster-whisper) overwrote the GPU build's native libraries during install while the stale onnxruntime_gpu dist-info kept claiming otherwise. Every ONNX-backed tool then silently ran on CPU.

The installer now reconciles the flavor before the venv merge and the GPU build always wins, in both install orders; reinstalling any GPU bundle repairs a previously clobbered venv. gpu.py's warning now says exactly that. Build-side, build-bundle.sh gains the same reconcile and verify-bundle-compatibility.sh layers bundles through the real installer merge and asserts a single flavor.

Verified live on an RTX 4070 against the published bundles: reproduced the clobber with the stock installer, then confirmed both the prevention and repair paths with the patched one.

Fixes #490
This commit is contained in:
SnapOtter
2026-07-17 00:25:32 +08:00
committed by GitHub
parent 846044a463
commit c8629c9d22
6 changed files with 430 additions and 3 deletions
+4 -2
View File
@@ -168,8 +168,10 @@ def onnx_providers():
available = _ort.get_available_providers()
if "CUDAExecutionProvider" in available:
return (["CUDAExecutionProvider", "CPUExecutionProvider"], "cuda")
emit_info("GPU detected by torch but CUDAExecutionProvider not available in onnxruntime "
"-- install onnxruntime-gpu for GPU acceleration")
emit_info("GPU detected by torch but CUDAExecutionProvider is missing from onnxruntime. "
"A bundle install likely replaced onnxruntime-gpu with the CPU build (#490); "
"reinstall the Background Removal bundle from Settings > AI Features to "
"restore the GPU build")
except ImportError:
emit_info("onnxruntime not installed, cannot check CUDA provider")
emit_info("No GPU detected, processing on CPU")