Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ By default, this crate is dynamically linked with the Faiss library installed in
so it does not build Faiss automatically for you.
To build the library yourself:

1. Follow the instructions [here](https://github.com/Enet4/faiss/tree/c_api_head/INSTALL.md#step-1-invoking-cmake)
to build Faiss using CMake,
1. Follow the [instructions to build Faiss using CMake](https://github.com/Enet4/faiss/tree/c_api_head/INSTALL.md#step-1-invoking-cmake),
enabling the variables `FAISS_ENABLE_C_API` and `BUILD_SHARED_LIBS`.
The crate is currently only compatible with version v1.7.2.
Consider building Faiss from [this fork, `c_api_head` branch](https://github.com/Enet4/faiss/tree/c_api_head),
Expand All @@ -39,14 +38,14 @@ To build the library yourself:

```toml
[dependencies]
"faiss" = "0.11.0"
"faiss" = "0.13.0"
```

If you have built Faiss with GPU support, you can include the "gpu" Cargo feature:

```toml
[dependencies]
"faiss" = { version = "0.11.0", features = ["gpu"] }
"faiss" = { version = "0.13.0", features = ["gpu"] }
```

## Installing with static linking
Expand All @@ -58,14 +57,14 @@ namely a compatible C++ compiler and a BLAS implementation.

```toml
[dependencies]
"faiss" = { version = "0.11.0", features = ["static"] }
"faiss" = { version = "0.13.0", features = ["static"] }
```

Compiling Faiss with GPU support is also possible.

```toml
[dependencies]
"faiss" = { version = "0.11.0", features = ["static", "gpu"] }
"faiss" = { version = "0.13.0", features = ["static", "gpu"] }
```

## Using
Expand Down
2 changes: 1 addition & 1 deletion src/index/id_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ where
/// While this method is safe, note that the returned index pointer is
/// already owned by this ID map. Therefore, it is undefined behavior to
/// create a high-level index value from this pointer without first
/// decoupling this ownership. See [`into_inner`] for a safe alternative.
/// decoupling this ownership. See [`into_inner`](Self::into_inner) for a safe alternative.
pub fn index_inner_ptr(&self) -> *mut FaissIndex {
self.index_inner
}
Expand Down
35 changes: 22 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@
//!
//! # Preparing
//!
//! This crate requires Faiss and the C API to be built beforehand by the
//! developer. Please follow the instructions
//! [here](https://github.com/facebookresearch/faiss/blob/master/INSTALL.md),
//! and build the dynamic library with the C API (instructions
//! [here](https://github.com/facebookresearch/faiss/blob/master/c_api/INSTALL.md))
//! This crate has two modes of linking.
//!
//! #### Dynamic linking
//!
//! By default, Faiss is dynamically linked,
//! so it requires Faiss and the C API
//! to be built beforehand by the developer.
//! Please follow the instructions
//! [here](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md),
//! and build the dynamic library with the C API (additional instructions
//! [here](https://github.com/facebookresearch/faiss/blob/main/c_api/INSTALL.md))
//!
//! This will result in the dynamic library `faiss_c` ("libfaiss_c.so" in Linux),
//! which needs to be installed in a place where your system will pick up. In
//! Linux, try somewhere in the `LD_LIBRARY_PATH` environment variable, such as
//! "/usr/lib", or try adding a new path to this variable.
//!
//! ## GPU support
//! #### Static linking
//!
//! Alternatively to the above, enable the `static` Cargo feature
//! to let Rust build Faiss for you.
//! You will still need the dependencies required to build and run Faiss
//! as described in their [INSTALL.md](https://github.com/facebookresearch/faiss/blob/main/INSTALL.md#building-from-source),
//! namely a compatible C++ compiler and a BLAS implementation.
//!
//! In order to have GPU support, the `gpufaiss_c` library from the main project
//! needs to be built instead. Then, enable the `gpu` Cargo feature for this crate.
//! ## GPU support
//!
//! ```toml
//! [dependencies]
//! "faiss" = {version = "0.12.0", features = ["gpu"]}
//! ```
//! Enable the cargo feature `gpu` for GPU support.
//! If you are using dynamic linking,
//! the Faiss library needs to be built with GPU capabilities.
//!
//! # Examples
//!
Expand Down Expand Up @@ -82,7 +92,6 @@
//! the [Faiss wiki](https://github.com/facebookresearch/faiss/wiki)
//! for additional guidance.
//!
#![doc(html_root_url = "https://docs.rs/faiss/0.12.0")]

#[macro_use]
mod macros;
Expand Down