Skip to content

Troubleshooting

Matthijs Douze edited this page Apr 5, 2018 · 33 revisions

We receive bug reports related to the GPU code that are not actionable because impossible to reproduce. If you start a bug report, please make sure to include (use a gist if it is too bulky):

  • version of OS, type of GPU, nvidia-smi output

  • output of ldd on executable or _swigfaiss_gpu.so for the Python version

  • a gdb stacktrace

  • please open a new issue unless you are certain that you have the exact same one as an existing one. This makes it easier for us to triage.

  • if you post code, please make it self-contained and as short as possible

Also, please consider the following notes on how to productively report bugs.

Python errors

ImportError: No module named swigfaiss

This means that Faiss was not compiled.

SWIG error

cd ../python; swig -Doverride= -python -c++ -DGPU_WRAPPER -o ../python/swigfaiss_gpu_wrap.cxx ../swigfaiss.swig
../gpu/StandardGpuResources.h:67: Error: Syntax error in input(3).
make: *** [../python/swigfaiss_gpu_wrap.cxx] error 1

This is probably because the swig version is too old (swig 2.0 does not parse C++11 >>), and you may have erased the swig-generated files by doing make clean. You can restore them by

cd ../python
git checkout swigfaiss_gpu_wrap.cxx swigfaiss_gpu.py swigfaiss_wrap.cxx swigfaiss.py

Then make py again.

NULL/nullptr/0

C++ has changed several times how NULL pointers should be represented. In the C++ source, we use nullptr. This is recognized by C++11 compliant compilers. If your flavor of C++ has another idea about this, pass option -Dnullptr=NULL to the compiler.

GPU Precomputed table error

If you get the following assertion error when constructing an GpuIndexIVFPQ with precomputed tables:

Faiss assertion usePrecomputed_ || IVFPQ::isSupportedNoPrecomputedSubDimSize( this->d / subQuantizers_) failed in void faiss::gpu::GpuIndexIVFPQ::assertSettings_() const at GpuIndexIVFPQ.cu:469Aborted (core dumped)

Then make sure that the ratio between the dimension and the PQ size (d/M) is one of the values mentioned in this function:

https://rawgit.com/facebookresearch/faiss/master/docs/html/PQScanMultiPassNoPrecomputed_8cu_source.html#l00029

If this is not the case, you can pre-process the input vectors with an OPQ transform.

undefined reference to operator new[]

Here you have probably erased the Faiss Makefile or forgotten to copy the makefile.inc as instructed in the INSTALL file.

What happens is that make is using a C compiler (cc) to compile C++.

Compile command without options

If you see

make
g++ -o tests/test_blas tests/test_blas.cpp

Then something happened with the Makefile. You may have overwritten it with makefile.inc for example.

Slow brute-force search with OpenBLAS

The search performance with OpenBLAS can degrade seriously because of a bad interaction between OpenMP and OpenBLAS threads. To avoid this, export OMP_WAIT_POLICY=PASSIVE before running the executable. See issue #53

Crashes in pure Python code

If you build nested indexes, you have to keep track of the references, Python will not do it for you.

This applies to quantizers in of IndexIVF objects for resources in GpuIndex objects and indexes used in IndexPreTransform objects (unless the objects have been created by index_factory), indexes added to IndexProxy or IndexShards.

For example, the following will crash:

index = faiss.IndexIDMap(faiss.IndexFlatL2(10))    # CRASH!

because the Python garbage collector does not realize that the IDMap has a pointer to FlatL2, so it will collect it. Correct version:

index_sub = faiss.IndexFlatL2(10)
index = faiss.IndexIDMap(index_sub)

However even this version will crash if used like:

def make_index(): 
  index_sub = faiss.IndexFlatL2(10)
  index = faiss.IndexIDMap(index_sub)
  return index    # CRASH!

On output of make_index, the index will be deallocated as well. To avoid this:

def make_index(): 
  index_sub = faiss.IndexFlatL2(10)
  index = faiss.IndexIDMap(index_sub)
  index.dont_dealloc_me = index_sub
  return index

this just adds a dynamic field to the index object, so that the refcount does not drop to 0 when returning from the function.

For completeness, this can also be done at the SWIG level with:

def make_index(): 
  index_sub = faiss.IndexFlatL2(10)
  index = faiss.IndexIDMap(index_sub)
  index_sub.this.disown()
  index.own_fields = True
  return index

This also applies to IndexIVF objects with a quantizer, to IndexPreTransform, etc.

We are thinking about how to make this more transparent.

Clone this wiki locally