AaronTekle commited on
Commit
7d171c2
·
verified ·
1 Parent(s): 28c7ecb

Update rag_engine.py

Browse files
Files changed (1) hide show
  1. rag_engine.py +5 -6
rag_engine.py CHANGED
@@ -1,6 +1,7 @@
1
  from __future__ import annotations
2
  import html
3
  import re
 
4
  import threading
5
  from dataclasses import dataclass
6
  import faiss
@@ -208,15 +209,13 @@ _LOCAL_MODEL_LOCK = threading.Lock()
208
 
209
  def get_embedding_device() -> str:
210
  """
211
- Use the NVIDIA GPU when available
212
-
213
- Fall back to CPU (automatically, if GPU not ready)
214
  """
215
 
216
- if torch.cuda.is_available():
217
- return "cuda"
218
 
219
- return "cpu"
220
 
221
 
222
  def get_embedder() -> SentenceTransformer:
 
1
  from __future__ import annotations
2
  import html
3
  import re
4
+ import os
5
  import threading
6
  from dataclasses import dataclass
7
  import faiss
 
209
 
210
  def get_embedding_device() -> str:
211
  """
212
+ embedding device
 
 
213
  """
214
 
215
+ if os.getenv("SPACES_ZERO_GPU"):
216
+ return "cpu"
217
 
218
+ return "cuda" if torch.cuda.is_available() else "cpu"
219
 
220
 
221
  def get_embedder() -> SentenceTransformer: