faiss python wheel packages.
This repository provides scripts to build wheel packages for the faiss library.
- Builds CPU-only version with cibuildwheel.
- Bundles OpenBLAS in Linux/Windows
- Uses Accelerate framework in macOS
There is also a source package to customize the build process.
Note GPU package has been supported until version 1.7.2, but is not available since version 1.7.3 due to the PyPI limitation.
Install a binary package by:
pip install faiss-cpu
If there is a custom built faiss library in the system, build source package for the best performance.
The source package assumes faiss is already built and installed in the system. Build and install the faiss library first.
cd faiss
cmake . -B build -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_OPT_LEVEL=avx2
cmake --build build --config Release -j
cmake --install build install
cd ..
See the official faiss installation instruction for more on how to build and install faiss.
For building sdist, swig 3.0.12 or later needs to be available.
By default, the following builds and installs the faiss-cpu package.
pip install --no-binary :all: faiss-cpu
The following example builds a GPU wheel.
export FAISS_ENABLE_GPU=ON
pip install --no-binary :all: faiss-cpu
There are a few environment variables that specifies build-time options.
CUDA_HOME
: Specifies CUDA install location for building faiss-gpu package.FAISS_OPT_LEVEL
: Faiss SIMD optimization, one ofgeneric
,avx2
. When set toavx2
, the package internally buildsavx2
extension in addition togeneric
. Note this option is only available in x86_64 arch.FAISS_ENABLE_GPU
: Setting this variable toON
buildsfaiss-gpu
package. Set this variable if faiss is built with GPU support.