Skip to content

Instantly share code, notes, and snippets.

@mdouze
Created September 6, 2022 09:28
Show Gist options
  • Save mdouze/2b96e804ee2825e72323c0a296061c7e to your computer and use it in GitHub Desktop.
Save mdouze/2b96e804ee2825e72323c0a296061c7e to your computer and use it in GitHub Desktop.
curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
bash ./Miniconda3-latest-MacOSX-arm64.sh
. $HOME/miniconda3/etc/profile.d/conda.sh
conda install python
conda install numpy
conda install swig
conda install cmake
export PATH=$HOME/miniconda3/bin:$PATH
git clone https://github.com/facebookresearch/faiss.git
cd faiss
cmake -B build -DBUILD_TESTING=ON -DFAISS_ENABLE_GPU=OFF \
-DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_C_API=ON \
-DPython_EXECUTABLE=$(which python)
make -k -C build -j faiss
# C++ tests do not work
# make -C build test
make -C build -j swigfaiss
cd build/faiss/python
python3 setup.py build
cd -
cd tests
PYTHONPATH=../build/faiss/python/build/lib/ python3 -m unittest discover
@bastos
Copy link

bastos commented Mar 22, 2023

✌️

brew install miniconda
brew install libomp

conda install python
conda install numpy
conda install swig
conda install cmake

cmake -B build -DBUILD_TESTING=ON -DFAISS_ENABLE_GPU=OFF \
  -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_C_API=ON \
  -DPython_EXECUTABLE=$(which python) \
  -DOpenMP_C_FLAGS=-fopenmp=lomp \
  -DOpenMP_CXX_FLAGS=-fopenmp=lomp \
  -DOpenMP_C_LIB_NAMES="libomp" -DOpenMP_CXX_LIB_NAMES="libomp" \
  -DOpenMP_libomp_LIBRARY="/opt/homebrew/opt/libomp/lib/libomp.dylib" \
  -DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp /opt/homebrew/opt/libomp/lib/libomp.dylib \
    -I/opt/homebrew/opt/libomp/include" -DOpenMP_CXX_LIB_NAMES="libomp" \
  -DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp  --I/opt/homebrew/opt/libomp/include"

make -k -C build -j faiss
make -C build -j swigfaiss

cd build/faiss/python
python3 setup.py build
cd - 
cd tests
PYTHONPATH=../build/faiss/python/build/lib/ python3 -m unittest discover

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment