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

Optimal build options for faiss CPU #1511

Closed
2 of 4 tasks
rom1504 opened this issue Nov 6, 2020 · 4 comments
Closed
2 of 4 tasks

Optimal build options for faiss CPU #1511

rom1504 opened this issue Nov 6, 2020 · 4 comments
Labels

Comments

@rom1504
Copy link

rom1504 commented Nov 6, 2020

Summary

We're compiling faiss ourselves to produce binaries adapted for our environment, we used the information provided in https://github.com/facebookresearch/faiss/blob/a17a631dc326b3b394f4e9fb63d0a7af475534dc/INSTALL.md
Precisely we're using https://github.com/victor-paltz/JFaiss-CPU/blob/master/Dockerfile to compile.
We observe that our build is much slower (5 times) for search than the build you provide with conda.

Do you have any advice on options/environment to use to get this optimized build?

Platform

OS: centos 7

Faiss version: 1.6.3

Installed from: compiled ourself vs conda 1.6.3

Faiss compilation options: https://github.com/victor-paltz/JFaiss-CPU/blob/master/Dockerfile
We're using MKL

Running on:

  • CPU
  • GPU

Interface:

  • C++
  • Python

Reproduction instructions

That's the benchmark script we used to measure the speed:
https://gist.github.com/rom1504/5a6a733dfd4772e497ea159e0395d0f9

Results:

  train reconstruct search
python (conda) 5 s 0.0024 ms 0.08 ms
custom build 30 s 0.0024 ms 0.38 ms

I would appreciate any advise on this, thanks!

@beauby
Copy link
Contributor

beauby commented Nov 6, 2020

The conda builds use MKL as a BLAS library, and have avx2 enabled. Those would be the main factors I think.

@rom1504
Copy link
Author

rom1504 commented Nov 6, 2020

Thanks, I'll check if we're properly using both MKL and AVX2

@mdouze mdouze added the install label Nov 6, 2020
@mdouze
Copy link
Contributor

mdouze commented Jan 5, 2021

At that point the AVX2 flags were not correct.

@mdouze mdouze closed this as completed Jan 5, 2021
@rom1504
Copy link
Author

rom1504 commented Jan 5, 2021

@mdouze ah that's interesting.
Did something change about these options in the new build system with cmake ?

On my side I did confirm I have the problem even with (I think) the right flags for avx2 and mkl and the last hypothesis I had was that the environment I used to compile the lib (GitHub action) didn't have the right cpu options itself.

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

No branches or pull requests

3 participants