Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing faiss on Google Colaboratory

I try to follow instruction on the MUSE project.

They require PyTorch and Faiss. PyTorch is easy to install. But I found problem with installing Faiss.

The instruction on MUSE tell me to use

conda install faiss-cpu -c pytorch

But Google Colab doesn't support conda (When I tried !pip install conda, it didn't work)

And Faiss didn't work when I !pip install faiss either.

Is there a way to install Faiss or conda?

like image 607
korakot Avatar asked Dec 25 '17 09:12

korakot


People also ask

How do I install faiss?

The recommended way to install Faiss is through conda. Stable releases are pushed regularly to the pytorch conda channel, as well as pre-release nightly builds. The CPU-only faiss-cpu conda package is currently available on Linux, OSX, and Windows.


1 Answers

Here's how I eventually install faiss.

!wget  https://anaconda.org/pytorch/faiss-cpu/1.2.1/download/linux-64/faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2
!tar xvjf faiss-cpu-1.2.1-py36_cuda9.0.176_1.tar.bz2
!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/
!pip install mkl

Then, I can import faiss with no problem. The warning is that I didn't use GPU. If you want to use GPU, you need to install this instead:

https://anaconda.org/pytorch/faiss-gpu/1.2.1/download/linux-64/faiss-gpu-1.2.1-py36_cuda9.0.176_1.tar.bz2

Update June 2020

As @Kuffner said, you can now use !pip to install it. (I test and simplify it a bit)

For CPU

!apt install libomp-dev
!pip install faiss

For GPU

!pip install faiss-gpu
like image 54
korakot Avatar answered Nov 28 '22 04:11

korakot