Yoxas commited on
Commit
19d04b0
·
verified ·
1 Parent(s): 0d2fb97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -28,13 +28,12 @@ data = data[data['embedding'].apply(lambda x: x.size > 0)]
28
  dimension = len(data['embedding'][0])
29
  res = faiss.StandardGpuResources() # use a single GPU
30
 
31
- # Check available GPU devices
32
- num_gpus = faiss.get_num_gpus()
33
- if num_gpus > 0:
34
  gpu_index = faiss.IndexFlatL2(dimension)
35
  gpu_index = faiss.index_cpu_to_gpu(res, 0, gpu_index) # move to GPU
36
  else:
37
- raise RuntimeError("No GPU devices available.")
38
 
39
  gpu_index.add(np.stack(data['embedding'].values))
40
 
 
28
  dimension = len(data['embedding'][0])
29
  res = faiss.StandardGpuResources() # use a single GPU
30
 
31
+ # Create FAISS index
32
+ if faiss.get_num_gpus() > 0:
 
33
  gpu_index = faiss.IndexFlatL2(dimension)
34
  gpu_index = faiss.index_cpu_to_gpu(res, 0, gpu_index) # move to GPU
35
  else:
36
+ gpu_index = faiss.IndexFlatL2(dimension) # fall back to CPU
37
 
38
  gpu_index.add(np.stack(data['embedding'].values))
39