From 0411000c03a763b7a7189164ae0a50d8bb511ca8 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 5 Aug 2025 13:01:32 +0800 Subject: [PATCH] . --- app/main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index e57b0d3..7a05788 100644 --- a/app/main.py +++ b/app/main.py @@ -185,7 +185,15 @@ def _encode(texts: List[str]): """ def _worker(t, q): try: - q.put(("ok", model.encode(t, return_dense=True))) + if DEVICE.startswith("cuda"): + # 正常 GPU 跑,多进程池照旧 + out = model.encode(t, return_dense=True) + else: + # 已经 fallback 到 CPU:禁用进程池,禁止再向 GPU 拷权重 + out = model.encode(t, return_dense=True, + num_processes=1, + device="cpu") + q.put(("ok", out)) except Exception as e: q.put(("err", str(e)))