Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
32 |
-
|
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 |
-
|
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 |
|