````
def create_faiss_index(vectors):
d = vectors.shape[1]
nlist = 1000
quantizer = faiss.IndexFlatL2(d)
indx = faiss.IndexIVFFlat(quantizer, d, nlist, faiss.METRIC_L2)
assert not indx.is_trained
indx.train(vectors)
assert indx.is_trained
indx.add(vectors)
return indx
def find_k_nearest(index, vectors, k=10, nprobe=10):
index.nprobe = nprobe
D, I = index.search(vectors, k)
return D, I
````
In the code index object is created in one function and is used in another. And it crushes with segmentation fault. BUT if I create and use index in the same function it works fine. R u going to fix it, guys?
Not entirely sure, but I think that the quantizer is being dropped from the moment you return the index from that function. Have you tried returning both the index and the quantizer from create_faiss_index?
@Enet4 thank you very much! It works.
See also
https://github.com/facebookresearch/faiss/wiki/Troubleshooting#crashes-in-pure-python-code
Most helpful comment
See also
https://github.com/facebookresearch/faiss/wiki/Troubleshooting#crashes-in-pure-python-code