Multi-GPU Sharding #3557
Unanswered
gorlando04
asked this question in
Q&A
Replies: 2 comments
-
This is probably because you are calling |
Beta Was this translation helpful? Give feedback.
0 replies
-
What should I use instead? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
Platform
4 NVIDIA GeForce RTX 2080 Super
Ubuntu 20.04
Cuda 12
Faiss version: 1.7.3
Installed from: anaconda
Faiss compilation options:
Running on:
Interface:
Reproduction instructions
I am trying to make a knn search using faiss in GPU using the multi-gpu indexes with sharding. But when im trying to execute the code it keeps to get MemoryError.
import numpy as np
from time import time
d = 12 # dimension
nb = 40000000 # database size
np.random.seed(1234) # make reproducible
xb = np.random.random((nb, d)).astype('float32')
import faiss # make faiss available
#Recall func
def recall(arr1,arr2,k):
ngpus = faiss.get_num_gpus()
print("number of GPUs:", ngpus)
for i in range(20000,1000,-512):
k = 20
t0 = time()
qntd = faiss.IndexFlatL2(d)
cpu_index = faiss.IndexIVFFlat(qntd,d,i,faiss.METRIC_L2)
cpu_index.nprobe = 13
print(f"Nlist = {i} nprobe = {cpu_index.nprobe}")
print("Fazendo o indice")
p = faiss.GpuMultipleClonerOptions()
p.shard = True
p.common_ivf_quantizer = True
gpu_index = faiss.index_cpu_to_all_gpus( # build the index
cpu_index,p
)
print("Training")
gpu_index.train(xb)
gpu_index.add(xb) # add vectors to the index
print(f"Tempo de treino = {time()-t0}")
Beta Was this translation helpful? Give feedback.
All reactions