2 unstable releases
0.2.0 | Feb 2, 2024 |
---|---|
0.1.1 | Jan 23, 2024 |
#738 in #version
Used in faiss-next
395KB
11K
SLoC
faiss-next-sys
faiss-next-sys
wrap c_api
of faiss
into rust
with bindgen
.
Currently supported faiss
version is v1.7.4
Build faiss
from source
faiss-next-sys
requires faiss
compiled with FAISS_ENABLE_C_API=ON
and BUILD_SHARED_LIBS=ON
.
Some facebookresearch/faiss distributions, like of brew
on mac, does not provide faiss_c
library.
So, building faiss
from source is necessary time to time.
facebookresearch/faiss provides installation document officially to guide how to build faiss
from source.
But, on windows
, building faiss
will fail, because of msvc
c++ compiler's implemention of C++17
syntax: issue.
So, a hecked v1.7.4
version is made: link to solve the issue.
If windows
is not the target platform, just clone faiss
and check v1.7.4
branch out, will just work fine.
- link: hecked version
- link offical version
Pick one of above, download, unzip, then start building:
MacOS
xcode
and brew
needed, install in advance.
# install cmake openblas and llvm
brew install cmake openblas llvm
# configure
cmake -B build -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF
# compile
cmake --build build --config Release
# install
cmake --install build --prefix=$HOME/faiss
cp build/c_api/libfaiss_c.dylib $HOME/faiss/lib/
Linux
gcc
, cmake
, intelmkl
, cuda
needed, install in advance.
# configure
cmake -B build -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF
# compile
cmake --build build --config Release
# install
cmake --install build --prefix=$HOME/faiss
cp build/c_api/libfaiss_c.so $HOME/faiss/lib/
Windows
Visual Studio 2022
, cmake
, intelmkl
, cuda
needed, install in advance.
# configure
cmake -B build -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF
# compile
cmake --build build --config Release
# install
cmake --install build --prefix=%USERPROFILE%\faiss
copy build\c_api\Release\faiss_c.dll %USERPROFILE%\faiss\bin
copy build\c_api\Release\faiss_c.lib %USERPROFILE%\faiss\lib\
Bindings
Bindings was generated by running the follow commands under faiss-next-sys
folder
cargo build --features bindgen
or, generate bindings with gpu
enabled
cargo build --features bindgen,gpu
Generated bindings looks like:
└── src
├── lib.rs
├── linux
│ ├── bindings.rs #linux cpu bindings
│ └── bindings_gpu.rs #linux gpu bindings
├── macos
│ └── bindings.rs #macos cpu bindings, gpu is not supported
└── windows
├── bindings.rs #windows cpu bindings
└── bindings_gpu.rs #windows gpu bindings
No runtime deps
~0–1.9MB
~37K SLoC