mirror of
https://github.com/facebookresearch/faiss.git
synced 2026-10-11 22:50:00 +00:00
Update c_api install docs for CMake build system (#4702)
Summary: Updates the C API installation documentation to reflect the current CMake-based build system. ## Changes - Replace outdated make-based instructions with clear CMake commands - Add step-by-step build instructions for both CPU and GPU configurations - Update library names and example paths to match current build output - Improve overall documentation clarity Fixes https://github.com/facebookresearch/faiss/issues/2421 ## Testing Documentation-only change, no code modifications. Pull Request resolved: https://github.com/facebookresearch/faiss/pull/4702 Reviewed By: trang-nm-nguyen Differential Revision: D88662666 Pulled By: mnorris11 fbshipit-source-id: f210c8f98f76972a1ad1aff86e3a2e10ab40e991
This commit is contained in:
committed by
meta-codesync[bot]
parent
abc294419a
commit
ac2e3abe38
+29
-16
@@ -6,17 +6,25 @@ Faiss provides a pure C interface, which can subsequently be used either in pure
|
||||
Compilation instructions
|
||||
------------------------
|
||||
|
||||
The full contents of the pure C API are in the ["c_api"](c_api/) folder.
|
||||
Please be sure to follow the instructions on [building the main C++ library](../INSTALL.md#step-1-compiling-the-c-faiss) first.
|
||||
Include `-DFAISS_ENABLE_C_API=ON` to the cmake command.
|
||||
The C API is built as part of the main Faiss build using CMake. From the root of the Faiss repository:
|
||||
|
||||
`make -C build`
|
||||
``` shell
|
||||
# Configure with C API enabled
|
||||
$ cmake -B build -DFAISS_ENABLE_C_API=ON .
|
||||
|
||||
# Build
|
||||
$ make -C build -j faiss_c
|
||||
```
|
||||
|
||||
This builds the dynamic library "faiss_c", containing the full implementation of Faiss and the necessary wrappers for the C interface. It does not depend on libfaiss.a or the C++ standard library.
|
||||
This builds the dynamic library `libfaiss_c.so` (or `.dylib` on macOS), containing the full implementation of Faiss and the necessary wrappers for the C interface.
|
||||
|
||||
To build the example program, you should run `make -C build example_c` at the top level of
|
||||
the faiss repo. The example program will be in `build/c_api/example_c` .
|
||||
To build the example program:
|
||||
|
||||
``` shell
|
||||
$ make -C build -j example_c
|
||||
```
|
||||
|
||||
The example program will be located at `build/c_api/example_c`.
|
||||
|
||||
Using the API
|
||||
-------------
|
||||
@@ -61,20 +69,19 @@ if (c) {
|
||||
}
|
||||
```
|
||||
|
||||
An example is included, which is built automatically for the target `all`. It can also be built separately:
|
||||
|
||||
`make bin/example_c`
|
||||
An example is included and can be built as shown in the compilation instructions above.
|
||||
|
||||
Building with GPU support
|
||||
-------------------------
|
||||
|
||||
For GPU support, a separate dynamic library in the "c_api/gpu" directory needs to be built.
|
||||
For GPU support, configure CMake with both GPU and C API enabled:
|
||||
|
||||
`make`
|
||||
``` shell
|
||||
$ cmake -B build -DFAISS_ENABLE_GPU=ON -DFAISS_ENABLE_C_API=ON .
|
||||
$ make -C build -j gpufaiss_c
|
||||
```
|
||||
|
||||
The "gpufaiss_c" dynamic library contains the GPU and CPU implementations of Faiss, which means that
|
||||
it can be used in place of "faiss_c". The same library will dynamically link with the CUDA runtime
|
||||
and cuBLAS.
|
||||
The `libgpufaiss_c.so` dynamic library contains both GPU and CPU implementations of Faiss, which means it can be used in place of `libfaiss_c.so`. This library dynamically links with the CUDA runtime and cuBLAS.
|
||||
|
||||
Using the GPU with the C API
|
||||
----------------------------
|
||||
@@ -101,4 +108,10 @@ c = faiss_index_cpu_to_gpu(gpu_res, 0, cpu_index, &gpu_index);
|
||||
if (c) { /* ... */ }
|
||||
```
|
||||
|
||||
A more complete example is available by the name `bin/example_gpu_c`.
|
||||
To build the GPU example:
|
||||
|
||||
``` shell
|
||||
$ make -C build -j example_gpu_c
|
||||
```
|
||||
|
||||
The example program will be located at `build/c_api/gpu/example_gpu_c`.
|
||||
|
||||
Reference in New Issue
Block a user