GPU users: onnxruntime (CPU) overwrites onnxruntime-gpu binaries when both are installed by pip/uv
メンテナーはふだん 4 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
pyproject.toml にある fastembed の依存関係の宣言と、現在 onnxruntime を必要としている import パスから始めます。提供されている uv および Docker コマンドで競合を再現し、提案されている GPU extra とガード付き import を評価します。GPU ユーザーが onnxruntime-gpu とともに fastembed をインストールしても両方のパッケージが互いに上書きせず、CPU インストールも引き続き機能すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 3.3k
- フォーク
- 314
- 平均マージ
- 5日 7時間
- マージ済み PR(30日)
- 23
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qdrant/fastembed のほかの issue
-
[Bug]: Bm25 splits Tamil, Hindi, Sinhala and other words on their combining marks対応中かも @Nipuna-Lakruwan が 12 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
qdrant/fastembed#886 · コメント 2 件 ·
メンテナーはふだん 4 日以内に返信
-
miniCOIL clean_words mutates input and loses counts when normalized words collide対応中かも @pear1-pea が 20 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 1/100
メンテナーはふだん 4 日以内に返信
-
[Bug]: Revision-pinned HF downloads can falsely report intact files as corrupted対応中かも @N7766 が 24 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 82/100
メンテナーはふだん 4 日以内に返信
-
[Bug]: URL-backed custom models with the same basename reuse the wrong cached model対応中かも @rtmalikian が 24 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
メンテナーはふだん 4 日以内に返信
-
[Bug]: rerank_pairs raises TypeError when pairs are passed as a tuple of pairs対応中かも @michaelkillgta が 53 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
メンテナーはふだん 4 日以内に返信
qdrant/fastembed の issue をすべて見る
似ている issue
-
DMB documentation good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
ubuntu/ubuntu-project-docs#921 ·
メンテナーはふだん 1 日以内に返信
-
⏳ Pending feedback 🐛 Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
jumpserver/jumpserver#18282 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
ClickHouse/loom#2014 ·
メンテナーはふだん 1 日以内に返信
-
accepted
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
future-agi/future-agi#5274 ·
メンテナーはふだん 1 日以内に返信
-
needs-triage
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 2 日以内に返信