GPU users: onnxruntime (CPU) overwrites onnxruntime-gpu binaries when both are installed by pip/uv
Maintainer thường phản hồi trong vòng 4 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu với các khai báo dependency của fastembed trong pyproject.toml và đường dẫn import hiện yêu cầu onnxruntime. Tái hiện xung đột bằng các lệnh uv và Docker được cung cấp, sau đó đánh giá extra GPU được đề xuất và import có bảo vệ. Công việc được xem là hoàn tất khi người dùng GPU có thể cài đặt fastembed cùng với onnxruntime-gpu mà hai package không ghi đè lên nhau, trong khi việc cài đặt cho CPU vẫn hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
When fastembed is used in a GPU environment alongside onnxruntime-gpu, the CUDAExecutionProvider silently disappears at runtime because pip/uv end up installing both onnxruntime (CPU) and onnxruntime-gpu simultaneously. Since both packages install into the same site-packages/onnxruntime/ directory, whichever is installed last wins — and in practice the CPU build's onnxruntime_pybind11_state.so overwrites the GPU build's, stripping CUDAExecutionProvider from the available providers list.
Root cause
fastembed declares a hard dependency on onnxruntime > 1.20.0 (by name). Until onnxruntime-gpu ~1.19.x, the GPU wheel declared Provides-Dist: onnxruntime in its metadata, which instructed pip/uv that onnxruntime-gpu satisfies any onnxruntime requirement. This metadata is absent from onnxruntime-gpu >= 1.20.0 (confirmed in 1.24.2). As a result:
- uv resolves
onnxruntime > 1.20.0→ installsonnxruntime==1.24.2(CPU build) - User also has
onnxruntime-gpu==1.24.2in their project requirements - Both install to
site-packages/onnxruntime/; the CPUonnxruntime_pybind11_state.sooverwrites the GPU one ort.get_available_providers()returns['CPUExecutionProvider']instead of['CUDAExecutionProvider', 'CPUExecutionProvider']
The failure mode is silent — no import error, no warning, just no GPU acceleration.
Minimal repro (Docker)
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
# Project that depends on fastembed + onnxruntime-gpu
RUN uv pip install fastembed onnxruntime-gpu
RUN python -c "import onnxruntime as ort; print(ort.get_available_providers())"
# Output: ['CPUExecutionProvider'] <-- CUDAExecutionProvider is gone
The libonnxruntime_providers_cuda.so is present and all its .so dependencies resolve correctly, but it links against Provider_GetHost from libonnxruntime_providers_shared.so — which is only exported by the GPU pybind11 build, not the CPU one. So dlopen of the CUDA provider fails silently.
Workaround
Reinstall onnxruntime-gpu after uv sync to restore the GPU binaries:
RUN uv sync --frozen --no-dev
RUN uv pip install --python .venv/bin/python --reinstall "onnxruntime-gpu[cuda,cudnn]==1.24.2"
This is fragile (order-dependent, easy to get wrong) and can't be expressed cleanly in pyproject.toml.
Suggested fixes
Option A — fastembed side (preferred): Add a gpu extra that replaces the onnxruntime dep with onnxruntime-gpu:
[project.optional-dependencies]
gpu = ["onnxruntime-gpu"]
[project.dependencies]
# Remove direct onnxruntime pin or make it conditional
And guard the import with try/except so either package works. This lets GPU users do pip install "fastembed[gpu]" and get a coherent environment.
Option B — onnxruntime side: Restore Provides-Dist: onnxruntime in onnxruntime-gpu's wheel metadata so package managers treat them as interchangeable. This was present in onnxruntime-gpu <= 1.19.x. A related issue is tracked at microsoft/onnxruntime#22107.
Environment
fastembed==0.7.4,onnxruntime==1.24.2,onnxruntime-gpu==1.24.2- Python 3.13, uv 0.6.x
- Docker image:
ghcr.io/astral-sh/uv:python3.13-bookworm-slim - Host: NVIDIA RTX 4090 + RTX 5090, driver 570.x, nvidia-container-toolkit 1.17.6
- Ngôn ngữ chính
- Python
- Star
- 3.3k
- Fork
- 314
- Merge trung bình
- 5 ngày 7 giờ
- Pull request đã merge (30 ngày)
- 23
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của qdrant/fastembed
-
[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marksCó thể đã có người làm @Nipuna-Lakruwan đã nhận 12 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 30/100
qdrant/fastembed#886 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
miniCOIL clean_words mutates input and loses counts when normalized words collideCó thể đã có người làm @pear1-pea đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 1/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: Revision-pinned HF downloads can falsely report intact files as corruptedCó thể đã có người làm @N7766 đã nhận 24 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached modelCó thể đã có người làm @rtmalikian đã nhận 24 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 4 ngày
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairsCó thể đã có người làm @michaelkillgta đã nhận 53 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 22/100
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của qdrant/fastembed
Issue tương tự
-
Ubuntu for Debian DevelopersĐang mởDMB documentation good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ubuntu/ubuntu-project-docs#921 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
⏳ Pending feedback 🐛 Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
jumpserver/jumpserver#18282 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
ClickHouse/loom#2014 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
accepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
future-agi/future-agi#5274 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 2 ngày