Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arm64 wheel for coremltools==5.0b3 contains x86 .so files (at least for Python 3.9) #1288

Closed
samueljohn opened this issue Aug 18, 2021 · 8 comments
Labels
bug Unexpected behaviour that should be corrected (type)

Comments

@samueljohn
Copy link

I downloaded the coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl for my M1 Mac.

However, import fails:

ImportError: dlopen(.../envs/IRE/lib/python3.9/site-packages/coremltools/libmodelpackage.so, 2): no suitable image found.  Did find:
	.../envs/IRE/lib/python3.9/site-packages/coremltools/libmodelpackage.so: mach-o, but wrong architecture
	.../envs/IRE/lib/python3.9/site-packages/coremltools/libmodelpackage.so: mach-o, but wrong architecture

(I replaced my path with ...)

And indeed unzipping the .whl file shows:

~ ❯ file ~/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libcoremlpyt
hon.so                                                                                                   
/Users/sam/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libcoremlpython.so: Mach-O 64-bit dynamically linked shared library x86_64
~ ❯ file ~/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libmilstorag
epython.so                                                                                               
/Users/sam/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libmilstoragepython.so: Mach-O 64-bit dynamically linked shared library x86_64
~ ❯ file ~/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libmodelpack
age.so                                                                                                   
/Users/sam/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl/coremltools/libmodelpackage.so: Mach-O 64-bit dynamically linked shared library x86_64

I have set up my python stack with miniforge completely for M1 arm64.

@samueljohn
Copy link
Author

Same thing if I pip install coremltools==5.0b3 (or with --pre). I will try to build from source ...

@samueljohn
Copy link
Author

nah, even when I build from source, in the ./build dir there are x86 files...

~/Do…/co…/build ❯ file libcoremlpython.dylib                                                                                      
libcoremlpython.dylib: Mach-O 64-bit dynamically linked shared library x86_64

I don't know why it is a .dylib and not a .so, though.

Now, I'll try to cd ./build %% ccmake . and then explicitly set the architecture ... maybe that helps?

@TobyRoseman
Copy link
Collaborator

Thanks for reporting this issue. I can reproduce the problem.

I don't know what's going on here, but this is a Python 3.9 issue. It works fine for me with Python 3.8.

@TobyRoseman TobyRoseman added the bug Unexpected behaviour that should be corrected (type) label Aug 18, 2021
@samueljohn
Copy link
Author

Nope. setting CMAKE_OSX_ARCHITECTURES to arm64 does not overwrite the setting that these protobuf stuff always wants to build x86_64. I don't know where to set it properly.

However, when I really set (in advanced mode of ccmake . by pressing t) CMAKE_CXX_FLAGS, CMAKE_C_FLAGS, and CMAKE_SHARED_LINKER_FLAGS to -arch arm64, I can at least build a universal binary. That means somewhere in there is perhaps a hardcoded -arch x86_64?

@TobyRoseman
Copy link
Collaborator

If you can use Python 3.8 rather than 3.9, pip install coremltools==5.0b3 works.

@samueljohn
Copy link
Author

Thanks, Toby, I might switch to py38 for now.

Using the "hack" to add -arch arm64 to different flags, allows me to built a universal binary that works.
I do not get a crash due to wrong architecture, however, I see a warning that my scikit-learn is too new, which puzzles me because I thought to read somewhere in the release notes that some scikit-learn newer than 0.19 was already supportet... (but that get's offtopic now)

(IRE) sam ~/Do…/coremltools-5.0b3 ❯ ipython                                                                                                 
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:00:30) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.26.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import coremltools
WARNING:root:scikit-learn version 0.23.2 is not supported. Minimum required version: 0.17. Maximum required version: 0.19.2. Disabling scikit-learn conversion API.

@akhenakh
Copy link

akhenakh commented Sep 1, 2021

Same problem, can we expect a release soon with the arm64 coremltools/libmodelpackage.so

pip install --force-reinstall  ~/Downloads/coremltools-5.0b3-cp39-none-macosx_11_0_arm64.whl
 file /Users/akh/dev/venvts/lib/python3.9/site-packages/coremltools/libmilstoragepython.so                                       
/Users/akh/dev/venvts/lib/python3.9/site-packages/coremltools/libmilstoragepython.so: Mach-O 64-bit dynamically linked shared library x86_64

@TobyRoseman
Copy link
Collaborator

This was fixed today in our beta 4 release. I've just verified that it is now working.

To install the newest version, run: pip install coremltools --pre -U.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour that should be corrected (type)
Projects
None yet
Development

No branches or pull requests

3 participants