Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save egolearner/530086589b588e46f8887070d361bd00 to your computer and use it in GitHub Desktop.
Save egolearner/530086589b588e46f8887070d361bd00 to your computer and use it in GitHub Desktop.
Install Facebook FAISS on macOS Catalina

Those instructions are working for me as of Nov. 2020. Using Homebrew and maOS 10.15.7

Install xCode command line tools (if you don't have it already)

xcode-select --install

Install LLVM

brew install llvm

Make sure /usr/local/opt/llvm/bin is in your PATH

Install Openblas

brew install openblas

Install swig

brew install swig

Clone FAISS

git clone https://github.com/facebookresearch/faiss.git

Make

CXX=/usr/local/opt/llvm/bin/clang++ CXXFLAGS="-fPIC -m64 -Wall -g -O3 -msse4 -mpopcnt -fopenmp -Wno-sign-compare -I/usr/local/opt/llvm/include -std=c++11 -I/usr/local/opt/openblas/include" LDFLAGS="-g -fPIC -fopenmp -L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib -L/usr/local/opt/openblas/lib" cmake -DFAISS_ENABLE_GPU=OFF -DOpenMP_CXX_LIB_NAMES=libomp -DOpenMP_libomp_LIBRARY=omp -DOpenMP_CXX_FLAGS="-fopenmp=libomp" -B build .
make -C build -j32
# build python
cd build/faiss/python && python setup.py install

Test

make -C build test

Test Python Interface

Run:

python -c "import faiss, numpy
faiss.Kmeans(10, 20).train(numpy.random.rand(1000, 10).astype('float32'))"

Note: you have to unzip faiss egg file, create folder the same as egg name, move zip contents to the egg dir. See this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment