Tokenizer
Tokenizer copied to clipboard
Build ARM64 wheels for macOS
Similarly to the recent CTranslate2 work (https://github.com/OpenNMT/CTranslate2/pull/769), we should publish ARM64 wheels for macOS. I had a first look but did not immediately find the correct configuration to cross-compile ICU for ARM64.
Related to https://github.com/OpenNMT/OpenNMT-py/issues/2154.
have you built a wheel for ARM64 on macOs? Can't get it to work...
No, there are still no ARM64 wheels for macOS (the issue is still open).
Do you want to help?
how could i help? Find a configuration to cross-compile ICU for ARM64 and create a script to build environment for macos arm64?
Hello,
I had built the wheel successfully on a Mac M1 but with the ICU libs installed with brew. If I recall correctly, I had to define the ICU cppflags and ldflags in the command line. Even though they were already in my .zshrc, for some reason they couldn't be picked up from there. As far as I understand, the problem is with the GitHub workflow which builds the ICU libs from source code.
Could you share the wheel you had built?
I'll search for it later tonight and share it here.
perfect, thank you!
@lukasloetkolben , Here it is, hope it works. pyonmttok-1.31.0-cp39-cp39-macosx_11_0_arm64.whl.zip
@lukasloetkolben , Here it is, hope it works. pyonmttok-1.31.0-cp39-cp39-macosx_11_0_arm64.whl.zip
'/Users/panos/miniforge3/lib/libOpenNMTTokenizer.dylib' (no such file)
it doesn't work.. Its referencing to your lib folder.
Ah, right. Try this one then and let me know. pyonmttok-1.31.0-cp39-cp39-macosx_12_0_arm64.whl.zip
When i try to import i get this error:
Referenced from: /Users/loetkolben/PycharmProjects/inspector_venv/lib/python3.9/site-packages/pyonmttok/_ext.cpython-39-darwin.so Reason: tried: '/usr/local/lib/libOpenNMTTokenizer.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/local/lib/libOpenNMTTokenizer.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e')), '/usr/lib/libOpenNMTTokenizer.dylib' (no such file)
While compiling i also get this warning:
building for macOS-x86_64 but attempting to link with file built for macOS-arm64
How can i compile it for arm64? Thanks for your help.
My experience with building wheels is little to none. I just built it so I can install and use OpenNMT-tf on my Mac M1.
Your error message confuses me though, as this wheel should be for arm64. Can you install it successfully with pip3 install
? @guillaumekln should be able to help here.
Thanks @panosk for you help. The wheel you shared does not seem to bundle the shared library libOpenNMTTokenizer.dylib
. The library can be bundled with the delocate tool.
As far as I understand, the problem is with the GitHub workflow which builds the ICU libs from source code.
Yes. The issue I faced is to figure out how to cross-compile ICU for ARM64 macOS on the x86-64 macOS GitHub runner. It's probably a specific flag or configuration to use, but I did not found it in the 2-3 hours I worked on this issue. Any help or insights would be useful.
You can find what a tried here.
I will work on that in the coming days and report back any findings.
Hi @panosk, did you have some time to investigate this cross compilation?
Hi @guillaumekln , sorry, I got stuck with a ton of other stuff. I will have some time to work on this during the weekend. Will let you know asap.
I tried but I couldn't cross-compile ICU on a x86_64 Mac and produce arm64 binaries. It's also discouraging that I can't find related info in Google or SO. Maybe we should post a question is SO?
Maybe there is another way. I found that brew
can download packages for other architectures: https://github.com/Homebrew/discussions/discussions/2843. So I downloaded the icu4c
binaries built for arm64_big_sur
and compiled the Tokenizer against this version.
The compilation worked, but I don't know if the final wheel is working.
Can anyone help test the wheels on macOS ARM? Go to this build page, download the "python-wheels" artifact, unzip, and install the appropriate wheel.
Hello @guillaumekln ,
I tested it on a Python 3.9 venv and it seems to be working fine!