hnswlib icon indicating copy to clipboard operation
hnswlib copied to clipboard

Apple M1 support?

Open stayrea1 opened this issue 3 years ago • 6 comments

I found that two packages having hsnw : faiss & hnswlib can not be installed in apple m1 silicon, so any solutions ? When will you support install on m1 silicon?

stayrea1 avatar Jul 22 '21 14:07 stayrea1

Hi @stayrea1, I do not have access to M1, though, my understanding is that there should be no obstacles for it to work. I wonder, what is the error that you are getting?

yurymalkov avatar Aug 02 '21 02:08 yurymalkov

There is also https://github.com/nmslib/hnswlib/pull/299 (it slipped away fro m attention). Can you test if it is working?

yurymalkov avatar Aug 02 '21 03:08 yurymalkov

Unfortunately, this still does not seem to work on M1 or am I doing anything wrong here: pip install hnswlib basically leads to the following error here (pip 21.3.1, Apple clang version 12.0.5 (clang-1205.0.22.9))

  clang: error: the clang compiler does not support '-march=native'
  error: command '/usr/bin/clang' failed with exit code 1
  ----------------------------------------
  ERROR: Failed building wheel for hnswlib

mkurovski avatar Feb 10 '22 16:02 mkurovski

@mkurovski Can you try with clang 13 and -mcpu=apple-m1?

yurymalkov avatar Feb 11 '22 22:02 yurymalkov

M1 user here. I didn't use #299, but I applied the following change to the CMakeLists.txt:11 (as described in #299):

11 11     if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
.. 12       if (APPLE)
.. 13            SET( CMAKE_CXX_FLAGS  "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -fpic -ftree-vectorize")
.. 14       else()
12 15          SET( CMAKE_CXX_FLAGS  "-Ofast -DNDEBUG -std=c++11 -DHAVE_CXX0X -openmp -march=native -fpic -ftree-vectorize")
.. 16       endif()

And was able to get python bindings to work. That is, I ran:

pip install hnswlib

And ran the python example from the README.

Jeadie avatar Feb 09 '23 04:02 Jeadie

This worked for me

ARCHFLAGS="-arch arm64" pip install hnswlib

Don't thank me.

sparfenyuk avatar Mar 27 '23 19:03 sparfenyuk