-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to control the max memory utilization that faiss search can take? #4131
Comments
How big is your index, query size and k & d? I can imagine if you want to optimize for memory, you can split up your query into smaller chunks. |
the index is 220GB+ , let's say the available memory is 60GB. I want if faiss or it's lower level dependencies (i.e openMP) have configuration to limit the memory it use? |
There are two possibilities here:
So what type of index are you using? |
I'm using |
Ah right. This is an OS mem management problem. Probably some option to ulimit should be able to limit it (-v or -d), see https://linuxcommand.org/lc3_man_pages/ulimith.html However, I would argue that using available memory to cache mmapped files is sane since this will take only unused memory. |
Thanks, @mdouze, In a scenario where FAISS search is run within a distributed processing framework like Dask, a Dask worker might initiate the FAISS search but later require additional memory for its own tasks, such as communicating with other workers. However, all available memory may already be consumed by FAISS mmap files. it sounds like there is no way that we can set a memory limit to faiss search at application-level. |
Hi Team,
I’m trying to load an index from disk in a memory-mapped way and perform a search on it. After loading the index using:
index = faiss.read_index('faiss.index', faiss.IO_FLAG_MMAP)
I noticed a slight increase in memory usage, which is expected. However, when I run a search:
distances, ids = index.search(query, k)
the memory usage spikes to 100%.
It seems that FAISS (via its C extension) aggressively utilizes memory during the search, especially if the index size exceeds available memory.
Is there a way to set a memory usage limit for FAISS during the search? My main challenge is running this code within a distributed framework like Dask. The Dask workers require their own memory allocation, but the FAISS search task consumes all available memory, causing the workers to fail.
Any advice or suggestions would be greatly appreciated. Thanks!
The text was updated successfully, but these errors were encountered: