Faiss: failed to load cpu

Created on 25 Jun 2018  路  13Comments  路  Source: facebookresearch/faiss

Platform

OS: Ubintu 14.04

Faiss version:

Faiss compilation options:

Running on :

  • [ ] CPU
  • [x] GPU

i installed faiss with INSTALL.MD file
currently, faiss is /usr/lib/python2.7/dist-package

so i tried "import faiss" and "res = faiss.StandardGpuResources()"
i got
'module' object has no attribute 'StandardGpuResources'

so tried
"import faiss" in the directory(faiss-master/python/build/(my-version)/faiss)

i got this error

Failed to load GPU Faiss: ./_swigfaiss_gpu.so: undefined symbol: omp_set_lock
Faiss falling back to CPU-only.

demos/demo_auto_tune.py with "use_gpu = False"
is well performed

but "use_gpu = True",
same error
'module' object has no attribute 'StandardGpuResources'

i modify makefile.inc to
-gencode arch=compute_61,code="compute_61"
-gencode arch=compute_61,code="compute_61"
cuz i use 1080Ti *2,
and

changed to
prefix ?= /usr/

nothig was touched except them

what's the problem.. ? i cannot find similar issue in this github page

install

Most helpful comment

I had similar issue (AttributeError: module 'faiss' has no attribute 'StandardGpuResources' ).
You can try the following steps to solve:

  1. pip uninstall faiss,
  2. build python wrapper again
  3. cd python; make _swigfaiss_gpu.so
  4. check that you can import faiss inside the python directory without installation.
  5. cd .. && make -C python install

I hope this will help.

All 13 comments

Same to you...

I am getting the same AttributeError: module 'faiss' has no attribute 'StandardGpuResources' error, but installed faiss via conda.

Hi
It seems that you installed CPU faiss instead of GPU.

@yurymalkov The current Faiss build on conda depends on the libomp provided by Homebrew. As a temporary workaround, you can do $ brew install libomp (in case you already have Homebrew installed).
The next conda release of Faiss will not have that issue and it will be available promptly.

I had similar issue (AttributeError: module 'faiss' has no attribute 'StandardGpuResources' ).
You can try the following steps to solve:

  1. pip uninstall faiss,
  2. build python wrapper again
  3. cd python; make _swigfaiss_gpu.so
  4. check that you can import faiss inside the python directory without installation.
  5. cd .. && make -C python install

I hope this will help.

No activity. Closing.

5. cd .. && make -C python install

this is essential.

This problem still happen in faiss-gpu-1.4.0 version through conda install

@beauby , Could you help give the specify conda release that can resolve the problem? Thank you very much !

I also tried faiss-gpu 1.5.0

root@b92569945f26:~# python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import faiss
>>> faiss.StandardGpuResources()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'faiss' has no attribute 'StandardGpuResources'
>>>
root@b92569945f26:~# conda list | grep faiss
faiss-gpu                 1.5.0            py36_cuda9.0_1  [cuda90]  pytorch

@zhjunqin
It might happen that faiss is build for GPU correcly, but the error AttributeError: module 'faiss' has no attribute 'StandardGpuResources' still appears.
The reason for this is that faiss cannot find cuda libraries. Explicitly setting the environmental variable LD_LIBRARY_PATH to point to cuda lib location is solving the problem.

export LD_LIBRARY_PATH='/path/to/cuda/lib'

just go to python folder and make gpu && make install.

As the Faiss conda package is now depending on the cudatoolkit conda package, there shouldn't be issues with Faiss not finding libcudart.so starting with version 1.5.1.

@novioleo Note that the build process was simplified in the latest version, and there is no need to do make gpu in the python folder anymore, but simply make && make install.

As the Faiss conda package is now depending on the cudatoolkit conda package, there shouldn't be issues with Faiss not finding libcudart.so starting with version 1.5.1.

@novioleo Note that the build process was simplified in the latest version, and there is no need to do make gpu in the python folder anymore, but simply make && make install.

thx for your reply.i'll try the v.1.5.1 release

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jukaradayi picture jukaradayi  路  3Comments

hipitt picture hipitt  路  3Comments

zoe-cheung picture zoe-cheung  路  3Comments

danny1984 picture danny1984  路  3Comments

wwmmqq picture wwmmqq  路  3Comments