This commit is contained in:
hailin 2025-08-05 13:01:32 +08:00
parent ca8f4a43bf
commit 0411000c03
1 changed files with 9 additions and 1 deletions

View File

@ -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)))