Open rationalga opened 3 months ago
index_cpu_to_all_gpus
is moving the data to GPU memory.
To reduce GPU memory utilization, you can shard the dataset over several GPUs setting shard = True
in the GpuMultipleClonerOptions
object.
Thank you for your reply.
Here is what I have understood so far:
When using the CPU-only implementation, the smaller index, i.e., populated.index, is loaded and then only the necessary nprobe number of inverted lists are loaded during the search:
index = faiss.read_index(tmpdir + "populated.index")
D, I = index.search(xq, 5)
However, in the case of the GPU implementation, the smaller index, i.e., populated.index, is loaded, but when we move this index to the GPU to perform the search, the entire index, including all inverted lists, is loaded into GPU memory.
index = faiss.read_index(tmpdir + "populated.index")
gpu_index = faiss.index_cpu_to_all_gpus(index)
Is there a way to move the index to the GPU for the search while only loading the nprobe number of inverted lists into GPU memory? I think sharding won't solve the out of memory issue if the inverted lists are too large for RAM. Thank you for your time and apologies if they are obviously silly questions.
Summary
Hi, I constructed a Faiss index that stores the inverted file data on disk as demonstrated in demo_ondisk_ivf.py. To speed up the search, I wanted to use GPUs. For demonstration purposes, below is how I added the GPU search as an additional stage to the above code.
I am encountering a memory usage issue with GPU-based search . The search operation works correctly, and I achieve the same recall as with the CPU implementation. However, I have observed that when I transfer the index to the GPU using faiss.index_cpu_to_all_gpus(index), the entire index (including the quantizer and all inverted lists) is loaded into GPU memory. In contrast, the CPU implementation only loads the necessary inverted lists depending on the nprobe value during the search (which is the desired behaviour here)
Could someone confirm if this is a current limitation of the OnDiskInvertedLists implementation for IVF indices in Faiss, or if there is an error in my approach? Any insights or solutions would be greatly appreciated. Thank you!
Question/ Problem
The GPU search seems to works fine and I get the same recall as well. The problem is that when we do index = faiss.index_cpu_to_all_gpus(index), the whole of index is moved to GPU i.e. quantizer + all of inverted lists wheres on CPU only implemenation dependng on nprobe only the selected inverted lists are loaded during search . Can anyone confirm if this is the current limitation of OnDiskInvertedDisk IVF or I am doing something wrong.
Thank you.