Spaces:
Paused
Paused
Commit ·
bed64db
1
Parent(s): cfa04f0
fix: force SentenceTransformer to CPU (ZeroGPU)
Browse filesSentenceTransformer's default auto-detects CUDA at __init__ and
moves the model there. Under ZeroGPU's CUDA emulation, that
initializes CUDA in the parent process, which then prevents
worker_init from binding a real GPU ("No CUDA GPUs are available"
at torch.init(nvidia_uuid)).
Matches the architecture invariant in README ("Embedding pre-filter
runs on CPU before the @spaces.GPU function is invoked").
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- candidate_filter.py +5 -1
candidate_filter.py
CHANGED
|
@@ -36,7 +36,11 @@ def load_embedder() -> SentenceTransformer:
|
|
| 36 |
global _embedder
|
| 37 |
if _embedder is None:
|
| 38 |
print(f"[candidate_filter] Loading {EMBEDDER_NAME}…")
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
return _embedder
|
| 41 |
|
| 42 |
|
|
|
|
| 36 |
global _embedder
|
| 37 |
if _embedder is None:
|
| 38 |
print(f"[candidate_filter] Loading {EMBEDDER_NAME}…")
|
| 39 |
+
# device="cpu" is required, not just intentional: SentenceTransformer's
|
| 40 |
+
# default auto-detects CUDA and moves the model there at __init__,
|
| 41 |
+
# which initializes CUDA in the parent process — fatal on ZeroGPU
|
| 42 |
+
# (worker_init then fails with "No CUDA GPUs are available").
|
| 43 |
+
_embedder = SentenceTransformer(EMBEDDER_NAME, device="cpu")
|
| 44 |
return _embedder
|
| 45 |
|
| 46 |
|