facebookresearch / faiss

A library for efficient similarity search and clustering of dense vectors.
https://faiss.ai
MIT License
30.93k stars 3.61k forks source link

OnDiskInvertedLists something wrong #1057

Open lockeliu opened 4 years ago

lockeliu commented 4 years ago
import os
import sys 
import numpy as np
import faiss

a = np.random.uniform(0,0.1,size=(100000,1024))
a = np.array( a, dtype = np.float32)
faiss_index = faiss.index_factory(a.shape[1], "IVF100,Flat")
faiss_index.train(a)
invlists = faiss.OnDiskInvertedLists(
        faiss_index.nlist, faiss_index.code_size,
        'test.ondisk')
faiss_index.replace_invlists( invlists )
faiss.write_index( faiss_index, "test_ondisk.faiss") 

faiss_index = faiss.read_index( "test_ondisk.faiss" )

when OnDiskInvertedLists is empty , I write index. It happen something wrong, when I read index again.

Traceback (most recent call last):
  File "test.py", line 16, in <module>
    faiss_index = faiss.read_index( "test_ondisk.faiss" )
RuntimeError: Error in void faiss::OnDiskInvertedLists::do_mmap() at OnDiskInvertedLists.cpp:243: Error: 'f' failed: could not open test.ondisk in mode r+: No such file or directory

Summary

Platform

OS:

Faiss version:

Faiss compilation options:

Running on:

Interface:

Reproduction instructions

mdouze commented 4 years ago

Right, when the index is empty, it does not create the ondisk file. I'll mark this as enhancement, but it does not seem high-priority to fix.