From 001dd2c575f4e8898b0c6ecfc263992652828156 Mon Sep 17 00:00:00 2001 From: Holden Date: Wed, 17 Jun 2026 02:53:05 +0000 Subject: [PATCH] fix: reinstall onnxruntime-gpu after uv sync to guarantee GPU binary wins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit insightface depends on onnxruntime (CPU) as a direct dependency. During uv sync --extra gpu, both onnxruntime (CPU, 24.6 MB binary) and onnxruntime-gpu (GPU, 24.7 MB binary) are installed in parallel — both claim onnxruntime/capi/onnxruntime_pybind11_state.so. The last writer wins, which is non-deterministic in uv's parallel installer. On GitHub Actions (no GPU, different scheduler ordering), the CPU binary consistently wins, leaving onnxruntime-gpu's pybind11_state.so as the CPU version. CUDAExecutionProvider then silently disappears because the CPU binary's provider registration code has no CUDA EP. Fix: after uv sync, reinstall onnxruntime-gpu explicitly using the already- cached wheel. Since uv pip install is synchronous and runs after the parallel sync completes, the GPU binary is guaranteed to be on disk when the build layer commits. --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6963cb0..0cfcf4c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,7 +50,9 @@ RUN if [ "$VARIANT" = "cpu" ]; then \ elif [ "$VARIANT" = "intel" ]; then \ uv sync --frozen --no-dev --extra intel; \ elif [ "$VARIANT" = "gpu" ]; then \ - uv sync --frozen --no-dev --extra gpu; \ + uv sync --frozen --no-dev --extra gpu && \ + ORT_GPU_VER=$(.venv/bin/python -c "import importlib.metadata; print(importlib.metadata.version('onnxruntime-gpu'))") && \ + uv pip install --python .venv/bin/python --no-deps --reinstall "onnxruntime-gpu==$ORT_GPU_VER"; \ else \ echo "Unknown VARIANT: '$VARIANT'. Must be one of: cpu, rocm, intel, gpu" >&2; \ exit 1; \