| Crates.io | faiss-next-sys |
| lib.rs | faiss-next-sys |
| version | 0.2.0 |
| created_at | 2024-01-23 13:28:56.36843+00 |
| updated_at | 2024-02-02 15:28:16.745198+00 |
| description | Light weighted rust wrapper of c api of facebookresearch/faiss library |
| homepage | http://github.com/yexiangyu/faiss-next |
| repository | https://github.com/yexiangyu/faiss-next |
| max_upload_size | |
| id | 1110824 |
| size | 392,607 |
faiss-next-sysfaiss-next-sys wrap c_api of faiss into rust with bindgen.
Currently supported faiss version is v1.7.4
faiss from sourcefaiss-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.
Pick one of above, download, unzip, then start building:
MacOSxcode 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/
Linuxgcc, 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/
WindowsVisual 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 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