Repository: erikbern/ann-benchmarks
Issue: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded  How can I solve it?
Root cause: Environment Incompatibility

python run.py --docker-tag ann-benchmarks-faiss  --dataset gist-960-euclidean --run-disabled --local  --batch 

ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.nmslib.NmslibReuseIndex([u'euclidean', 'sw-graph', {'NN': 16}, False]): warning: the module 'ann_benchmarks.algorithms.nmslib' could not be loaded; skipping
ann_benchmarks.algorithms.panns.PANNS([u'euclidean', 10, 50]): warning: the module 'ann_benchmarks.algorithms.panns' could not be loaded; skipping
ann_benchmarks.algorithms.nmslib.NmslibReuseIndex([u'euclidean', 'vptree', {'tuneK': 10, 'desiredRecall': 0.4}, False]): warning: the module 'ann_benchmarks.algorithms.nmslib' could not be loaded; skipping
ann_benchmarks.algorithms.nearpy.NearPy([u'euclidean', 16, 20]): warning: the module 'ann_benchmarks.algorithms.nearpy' could not be loaded; skipping
ann_benchmarks.algorithms.mrpt.MRPT([u'euclidean', 25, 2]): warning: the module 'ann_benchmarks.algorithms.mrpt' could not be loaded; skipping
ann_benchmarks.algorithms.nmslib.NmslibReuseIndex([u'euclidean', 'vptree', {'tuneK': 10, 'desiredRecall': 0.9}, False]): warning: the module 'ann_benchmarks.algorithms.nmslib' could not be loaded; skipping
ann_benchmarks.algorithms.hnswlib.HnswLib([u'euclidean', {'efConstruction': 500, 'M': 48}]): warning: the module 'ann_benchmarks.algorithms.hnswlib' could not be loaded; skipping
ann_benchmarks.algorithms.pynndescent.PyNNDescent([u'euclidean', 10, 4, 20]): warning: the module 'ann_benchmarks.algorithms.pynndescent' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss.FaissIVF([u'euclidean', 8192]): warning: the module 'ann_benchmarks.algorithms.faiss' could not be loaded; skipping
ann_benchmarks.algorithms.hnswlib.HnswLib([u'euclidean', {'efConstruction': 500, 'M': 8}]): warning: the module 'ann_benchmarks.algorithms.hnswlib' could not be loaded; skipping
ann_benchmarks.algorithms.nmslib.NmslibReuseIndex([u'euclidean', 'vptree', {'tuneK': 10, 'desiredRecall': 0.2}, False]): warning: the module 'ann_benchmarks.algorithms.nmslib' could not be loaded; skipping
ann_benchmarks.algorithms.faiss.FaissIVF([u'euclidean', 512]): warning: the module 'ann_benchmarks.algorithms.faiss' could not be loaded; skipping
ann_benchmarks.algorithms.hnswlib.HnswLib([u'euclidean', {'efConstruction': 500, 'M': 24}]): warning: the module 'ann_benchmarks.algorithms.hnswlib' could not be loaded; skipping
ann_benchmarks.algorithms.faiss.FaissIVF([u'euclidean', 1024]): warning: the module 'ann_benchmarks.algorithms.faiss' could not be loaded; skipping
ann_benchmarks.algorithms.flann.FLANN([u'euclidean', 0.9]): warning: the module 'ann_benchmarks.algorithms.flann' could not be loaded; skipping

Hi! 

To run faiss in gpu mode you have to build it locally on your machine. (Docker is not supported at the moment.) Please try to install it according to https://github.com/facebookresearch/faiss/blob/master/INSTALL.md and report back if it still doesn't work. 

Thanks!



I have installed faiss_gpu.
python run.py  --dataset gist-960-euclidean --run-disabled --local --batch  

 triggered the same error，What is the correct command line?


It should be `python run.py --dataset gist-960-euclidean --run-disabled --local --batch --algo faiss-gpu` (to only run `faiss-gpu`). 

Does `python -c "import _swigfaiss_gpu"` run without an error?

sudo python run.py --dataset gist-960-euclidean --run-disabled --local --batch --algo faiss-gpu
('running only', 'faiss-gpu')
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 100]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([16384, 40]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 40]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([16384, 200]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([16384, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 40]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 100]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([8192, 10]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 100]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 200]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([8192, 200]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 40]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([16384, 100]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([8192, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([8192, 40]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([16384, 1]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([1024, 200]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([8192, 100]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
ann_benchmarks.algorithms.faiss_gpu.FaissGPU([4096, 200]): warning: the module 'ann_benchmarks.algorithms.faiss_gpu' could not be loaded; skipping
Traceback (most recent call last):
  File "run.py", line 3, in <module>
    main()
  File "/home/tianyu.zhen/ann-benchmarks/ann_benchmarks/main.py", line 184, in main
    raise Exception('Nothing to run')


python -c "import _swigfaiss_gpu"   
no error return


Is that from the same directory as the one where you run ann-benchmarks from? Do you have a local installation of faiss still in a directory `faiss/` that you could move inside the `ann-benchmarks` folder?That's how it works for me. (I don't have faiss in my Python path by default.)

```
python run.py --dataset glove-100-angular --run-disabled --local --batch --algo faiss-gpu
('running only', 'faiss-gpu')
('Order:', [Definition(algorithm='faiss-gpu', constructor='FaissGPU', module='ann_benchmarks.algorithms.faiss_gpu', docker_tag='ann-benchmarks-faiss', arguments=[400, 200], query_argument_groups=[], disabled=False),  '...')
Trying to instantiate ann_benchmarks.algorithms.faiss_gpu.FaissGPU([400, 200])
got a train set of size (1183514 * 100)
got 10000 queries
Built index in 2.36437511444
Index size:  579364
Running query argument group 1 of 1...
Run 1/2...
```



> Docker is not supported at the moment.

Can we fix this? So much easier to have things running out of Docker. I know sometimes with Docker it's harder to get GPU working though

>> Docker is not supported at the moment.

> Can we fix this? So much easier to have things running out of Docker. I know sometimes with Docker it's harder to get GPU working though

That would be awesome! However, I have no experience with this setup. (I used nvidia-docker for getting the GPU to work inside of a docker container in other projects, and I don't know if it has gotten easier with a default docker installation by now.)

Yeah I don't know either. Maybe we can move everything to nvidia-docker optionally.