Faiss: IndexIDMap2 Segmentation fault (core dumped

Created on 13 Jan 2018  ·  3Comments  ·  Source: facebookresearch/faiss

core dumped

Failed to load GPU Faiss: No module named swigfaiss_gpu
Faiss falling back to CPU-only.
True
Segmentation fault (core dumped)
[root@cuda python]# python 1-Flat.py
Failed to load GPU Faiss: No module named swigfaiss_gpu
Faiss falling back to CPU-only.
True
Segmentation fault (core dumped)

`

from __future__ import print_function
import numpy as np

d = 64                           # dimension
nb = 100000                      # database size
nq = 10000                       # nb of queries
np.random.seed(1234)             # make reproducible
xb = np.random.random((nb, d)).astype('float32')
xb[:, 0] += np.arange(nb) / 1000.
xq = np.random.random((nq, d)).astype('float32')
xq[:, 0] += np.arange(nq) / 1000.

import faiss                   # make faiss available
index = faiss.IndexFlatL2(d)   # build the index
index = faiss.IndexIDMap2(index)
print(index.is_trained)
#index.add(xb)                  # add vectors to the index
index.add_with_ids(xb, np.arange(nb))
print(index.ntotal)

k = 4                          # we want to see 4 nearest neighbors
D, I = index.search(xb[:5], k) # sanity check
print(I)
print(D)
D, I = index.search(xq, k)     # actual search
print(I[:5])                   # neighbors of the 5 first queries
print(I[-5:])                  # neighbors of the 5 last queries

`
new code:

def add_with_ids(self, n, x, xids):
       return _swigfaiss.IndexIDMap2_add_with_ids(self, n, x, xids)

Is it the reason that the new method has more parameters? Do you have an example of the new code?

Most helpful comment

The faiss.IndexFlatL2 is deallocated but the faiss.IndexIDMap2 still has a reference to it.

To avoid this:

indexa = faiss.IndexFlatL2(d)   # build the index
index = faiss.IndexIDMap2(indexa)

All 3 comments

@mdouze help help !!

The faiss.IndexFlatL2 is deallocated but the faiss.IndexIDMap2 still has a reference to it.

To avoid this:

indexa = faiss.IndexFlatL2(d)   # build the index
index = faiss.IndexIDMap2(indexa)

@mdouze thanks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zoe-cheung picture zoe-cheung  ·  3Comments

siva2k16 picture siva2k16  ·  3Comments

maozezhong picture maozezhong  ·  3Comments

linghuang picture linghuang  ·  3Comments

hashyong picture hashyong  ·  3Comments