keyvi binary not compiled for m1 mac
Closed this issue · 4 comments
Ok, so now I'm trying to get keyvi working on my m1 mac.
It pip installs fine, but as soon as I try to import it, I get the following:
Traceback (most recent call last):
File "[redacted]", line 2, in <module>
import keyvi.compiler
File "/Users/ysaxon/.pyenv/versions/3.9.10/lib/python3.9/site-packages/keyvi/__init__.py", line 23, in <module>
from keyvi._core import MatchIterator, Match, loading_strategy_types
ImportError: dlopen(/Users/ysaxon/.pyenv/versions/3.9.10/lib/python3.9/site-packages/keyvi/_core.cpython-39-darwin.so, 0x0002): tried: '/Users/ysaxon/.pyenv/versions/3.9.10/lib/python3.9/site-packages/keyvi/_core.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/_core.cpython-39-darwin.so' (no such file), '/usr/lib/_core.cpython-39-darwin.so' (no such file)
The key line in there seems to be the following
_core.cpython-39-darwin.so' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e'))
I'm working on compiling the core library myself right now, so if you don't have access to an M1 mac, let me know if there's anything special I should do to build a .so that you could include in the pip repo.
We don't have M1 support at the moment. It seems to me that pip should not install the x86_64
pre-compiled package on M1.
I don't have access to an M1 machine, maybe @narekgharibyan can help.
We also lack packages for arm on Linux, but I can say it works. Note that keyvi has some special optimizations (intrinsics) for x86_64
, for arm it has to fallback to a slower default implementation. With other words, there is room for improvement on arm.
Please continue sharing your findings, it is much appreciated.
I have got my M1 just a few days ago, but had no chance to look into building m1 wheels yet.
I'll be mostly offline upcoming days, but am planning on looking into that after am back online.
ok, so this took me a while to figure out, but I think I got it compiled properly
the key was removing lines 328-329 in setup.py
Line 328 in d45ba35
after I did this on a fresh git clone and ran python setup.py build
, it returned an error ld: unknown option: -Bstatic
, but when I copy pasted the clang++ command and manually removed the -Wl,-Bstatic
(and then after it complained again) the -Wl,-Bdynamic
, it compiled fine, and then I was able to setup.py build
and setup.py install
There's probably a way to stop those dynamic and static flags in cmake somewhere (do a search for "Darwin"
), but I didn't bother figuring that out.
Anyway it seems to be working I think.. time will tell..
If I can be of any further help, please let me know.
@YSaxon earlier today keyvi v0.5.4 was release.
It comes with pre-build binary wheels for M1 chip, as well as fixed source distribution.
You can see those available on: https://pypi.org/project/keyvi/0.5.4/#files
I'll be closing this issue, please let us know if you encounter any further issues.