faiss-rs icon indicating copy to clipboard operation
faiss-rs copied to clipboard

Support for mac m1?

Open vvbae opened this issue 2 years ago • 7 comments

I successfully installed faiss via brew with command: brew reinstall faiss --build-from-source it runs cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON. I could add to my project faiss = "0.12.1", but when I try to run it it says note: ld: library not found for -lfaiss_c

vvbae avatar Sep 17 '23 16:09 vvbae

I successfully installed faiss via brew with command: brew reinstall faiss --build-from-source it runs cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON. I could add to my project faiss = "0.12.1", but when I try to run it it says note: ld: library not found for -lfaiss_c

I use + -DBUILD_SHARED_LIBS=ON

after run

make -C build -j8 faiss_c

ava57r avatar Sep 18 '23 10:09 ava57r

I successfully installed faiss via brew with command: brew reinstall faiss --build-from-source it runs cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON. I could add to my project faiss = "0.12.1", but when I try to run it it says note: ld: library not found for -lfaiss_c

I use + -DBUILD_SHARED_LIBS=ON

after run

make -C build -j8 faiss_c

I didn't build from the source like in INSTALL.MD, because the repo says mac m1 is not supported, so I followed the instructions at here which compiles faiss with brew.

The screenshot: Screenshot 2023-09-18 at 1 54 36 PM

So I didn't run any CMake or make commands myself, as I think they won't run on my machine.

vvbae avatar Sep 18 '23 18:09 vvbae

I successfully installed faiss via brew with command: brew reinstall faiss --build-from-source it runs cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON. I could add to my project faiss = "0.12.1", but when I try to run it it says note: ld: library not found for -lfaiss_c

I use + -DBUILD_SHARED_LIBS=ON after run make -C build -j8 faiss_c

I didn't build from the source like in INSTALL.MD, because the repo says mac m1 is not supported, so I followed the instructions at here which compiles faiss with brew.

The screenshot: Screenshot 2023-09-18 at 1 54 36 PM

So I didn't run any CMake or make commands myself, as I think they won't run on my machine.

You can build from source on an M1 mac.

Give:

git clone https://github.com/Enet4/faiss.git
cd faiss
cmake -B build -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_PYTHON=OFF
cmake --build build
make -C build -j8 faiss_c

A try. Then add it to your libraries with, for example,

cp /path/to/faiss/build/c_api/libfaiss_c.dylib /usr/local/bin

DevinLeamy avatar Oct 12 '23 15:10 DevinLeamy

@DevinLeamy The above doesn't work on M1 (at least, not on the stock faiss package) due to https://github.com/facebookresearch/faiss/issues/2111 . According to that you need to install llvm from brew and then pass several additional arguments to the faiss build to make use of it.

ceejatec avatar Oct 16 '23 23:10 ceejatec

~I am also having an issue especially on running python tests which I think -DFAISS_ENABLE_PYTHON=ON is needed during build time.~

heemin32 avatar Jul 09 '24 21:07 heemin32

I am also having an issue especially on running python tests which I think -DFAISS_ENABLE_PYTHON=ON is needed during build time.

It is pretty much outside this crate's intention to run any tests. If you are saying that they are being run by CMake despite the FAISS_ENABLE_PYTHON definition being disabled, then that is unexpected and should be treated as a bug, either from here or the main Faiss project.

Enet4 avatar Jul 10 '24 08:07 Enet4

@Enet4 Sorry for the fuss. I was trying to build faiss from source and I came to a wrong place.

heemin32 avatar Jul 10 '24 16:07 heemin32