Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to latest faiss? #72

Open
jondot opened this issue Aug 28, 2023 · 9 comments
Open

Updating to latest faiss? #72

jondot opened this issue Aug 28, 2023 · 9 comments

Comments

@jondot
Copy link

jondot commented Aug 28, 2023

I've forked @SkyFan2002 's static build, and in the effort to simplify, I've also updated to latest Faiss:
https://github.com/jondot/faiss-rs
Compiling on Mac M1 and running vector search and indexing works well.

As now we have static build in this repo, I'm wondering if its possible to point to a recent Faiss version (and not a specific C_api flavor), or there's something hidden from my knowledge that forbids that?

@Enet4
Copy link
Owner

Enet4 commented Aug 28, 2023

Updating the inner Faiss to v1.7.4 seems like a good plan for v0.13.0. If you would like to send in a PR, the steps would be:

  1. Update the scripts in faiss-sys to point to v1.7.4
  2. Run gen_bindings.sh (may need tweaking depending on the version of bindgen used)
  3. Include changes to bindings.rs and bindings_gpu.rs
  4. Adjust code at faiss if necessary

@jondot
Copy link
Author

jondot commented Aug 28, 2023

on the fork up top i just updated the git submodule without running gen_bindings or any source updates.
having said that, I selfishly built for my Mac M1 only, you're saying that if I attempt building for other platforms I might need these kind of tweaks?

@Enet4
Copy link
Owner

Enet4 commented Aug 28, 2023

I'm not sure if I understood you correctly. Do you want to use a custom version of the Faiss library? That makes things a bit trickier. You will either need to depend on dynamic linking (assuming the C API is left working and compatible), or bring those changes upstream to Faiss so that they are released officially in a future version.

The changes I mentioned above are necessary to target a new version of Faiss, regardless of platform. Since Faiss does not follow semver, the crate is intended to always target a specific version of the library, or a version with a compatible C API.

@jondot
Copy link
Author

jondot commented Aug 28, 2023

What I'm saying is that I went ahead and updated my personal fork to this https://github.com/facebookresearch/faiss/commits/v1.7.4

And without running any binding gen steps, building statically, everything worked.

So i'm wondering -- did everything work only because I built for Mac? or if I tried building for other platforms, then I would need to do gen_bindings etc.

Hope that's clearer?

@Enet4
Copy link
Owner

Enet4 commented Aug 28, 2023

I mean, it might have worked because of the range of API compatibility between those versions, but that may have been purely coincidental. In addition, new parts of the API are not exposed by faiss-sys unless the bindings are regenerated. So a complete Faiss upgrade should still go through the full process.

@jondot
Copy link
Author

jondot commented Aug 28, 2023

Got it, thanks!

@web3creator
Copy link

web3creator commented Sep 5, 2023

I've forked @SkyFan2002 's static build, and in the effort to simplify, I've also updated to latest Faiss: https://github.com/jondot/faiss-rs Compiling on Mac M1 and running vector search and indexing works well.

As now we have static build in this repo, I'm wondering if its possible to point to a recent Faiss version (and not a specific C_api flavor), or there's something hidden from my knowledge that forbids that?

@jondot hello,I hava a bug on mac m1

  = note: ld: library not found for -lgomp

do you know what's going on?


I hava installed libopm
(base) simonyi@simondeMacBook-Pro-2 faiss-rs %  brew info libomp
==> libomp: stable 16.0.6 (bottled) [keg-only]
LLVM's OpenMP runtime library
https://openmp.llvm.org/
/opt/homebrew/Cellar/libomp/16.0.6 (7 files, 1.7MB)
  Poured from bottle using the formulae.brew.sh API on 2023-09-05 at 13:57:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libomp.rb
License: MIT
==> Dependencies
Build: cmake ✔, lit ✔
==> Caveats
libomp is keg-only, which means it was not symlinked into /opt/homebrew,
because it can override GCC headers and result in broken builds.

For compilers to find libomp you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/libomp/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/libomp/include"
==> Analytics
install: 19,756 (30 days), 80,619 (90 days), 231,651 (365 days)
install-on-request: 3,859 (30 days), 16,318 (90 days), 46,744 (365 days)
build-error: 2 (30 days)

@jondot
Copy link
Author

jondot commented Sep 5, 2023

yes, on mac, we need omp and not gomp, and after omp is specified in build.rs, then you need to have libomp on your computer.

@jondot
Copy link
Author

jondot commented Sep 5, 2023

@Enet4 I haven't yet moved back to your repo, so these are the relevant lines:
https://github.com/jondot/faiss-rs/blob/master/faiss-sys/build.rs#L39-L43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants