faiss icon indicating copy to clipboard operation
faiss copied to clipboard

How to build in msys2

Open thewh1teagle opened this issue 1 year ago • 4 comments

Hello I would like to build faiss on windows using mingw64 in msys2 with mkl / openblas

Is there some place with instructions for that? I already tried and currently I'm facing issues with cmake which doesn't find mkl or openblas.

thewh1teagle avatar Sep 16 '23 02:09 thewh1teagle

Please let us know if any progress in this environment.

mdouze avatar Sep 27 '23 14:09 mdouze

I managed to build it on Windows in msys2 environemnt! I had to change a little the source code to support MinGW compiler.

  1. Download msys2 from https://www.msys2.org/

  2. Open UCRT64 terminal Install dependencies

pacman --needed -S $MINGW_PACKAGE_PREFIX-{toolchain,cmake,make,swig,autotools,lapack} git
  1. Clone & Build
git clone https://github.com/thewh1teagle/faiss -b windows-mingw-support
cd faiss
cmake -B build . -G "MinGW Makefiles" -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DCMAKE_CXX_FLAGS="-march=x86-64" -DCMAKE_C_FLAGS="-march=x86-64" -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTING=off
cmake --build build -- -j16

thewh1teagle avatar Dec 31 '23 18:12 thewh1teagle

I am trying to compile under mingw as well, but am hitting the issue that mingw doesn't define posix_memalign (used in AlignedTable.h). Did you hit the same issue?

JAicewizard avatar Jul 09 '24 12:07 JAicewizard

I am trying to compile under mingw as well, but am hitting the issue that mingw doesn't define posix_memalign (used in AlignedTable.h). Did you hit the same issue?

Try in ucrt. Anyway, compiling this in msys2 environment is not something I would recommend, as in the end you'll need the DLLs of that environment so you will be able to run it outside of the environment. I would switch to other libs with better support for Windows such as spotify/annoy

thewh1teagle avatar Jul 09 '24 12:07 thewh1teagle

We only support installing and building FAISS through conda on Windows. Here is an example nightly build that compiles FAISS on Microsoft Windows Server 2019: https://fburl.com/hbbh3ndc and the yaml file backing up that build is in https://fburl.com/code/2xcnxa77 (check the platform specific selectors for windows)

You can step through the instructions there which provide all of the related conda installation commands and the compilation arguments.

Feel free to re-open the issues if you struggle with building on windows + conda

mengdilin avatar Jul 19 '24 22:07 mengdilin