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

Apple M1 chip compilation support #4369

Closed
fayeshine opened this issue Jun 10, 2021 · 11 comments
Closed

Apple M1 chip compilation support #4369

fayeshine opened this issue Jun 10, 2021 · 11 comments

Comments

@fayeshine
Copy link

We can only compile LGB by x86 instruction set now, however apple m1 has much higher performance with ARM instruction set. If we use x86 version, the mac with M1 will run in a intel compatible mode (need compile translation) and the performance is much lower. So I suggest we support mac M1's ARM instruction set.

@StrikerRUS
Copy link
Collaborator

Hey @fayeshine !

Do you have logs of failed compilation on Apple M1?
We've recently started to provide Python wheels for ARM64 (aarch64) platform and had no problems with compilation.

Also, Homebrew provides LightGBM bottles for arm64_big_sur.
https://github.com/Homebrew/homebrew-core/blob/2e25c708a3f396feb76dd5d9ce74e1641378aa85/Formula/lightgbm.rb#L10
I guess they compile with native ARM support.

@fayeshine
Copy link
Author

@StrikerRUS Hi,

I found that the python wheels for arm64 is for linux, do we have arm64 wheel for mac?

@StrikerRUS
Copy link
Collaborator

do we have arm64 wheel for mac?

Unfortunately, we don't.

@fayeshine
Copy link
Author

@StrikerRUS homebew's arm64 version is a command line program, not a python package, so could we provide a arm64 wheel for mac? Or could you tell me how to compile with arm64 instruction set on mac, it seems that cmake automatically compile into an intel version.

@StrikerRUS
Copy link
Collaborator

My example with Homebrew was about possibility of compilation on ARM platform. Unfortunately, we can't provide wheels right now due to infrastructure limitations. We are looking forward for mac M1 availability on free CI services (e.g. actions/runner-images#2187 (comment)).

Or could you tell me how to compile with arm64 instruction set on mac, it seems that cmake automatically compile into an intel version.

What makes you think so? Please share the logs here. Also, I believe it worth using the latest CMake.
Try passing -DCMAKE_OSX_ARCHITECTURES=arm64.
https://gitlab.kitware.com/cmake/cmake/-/issues/20989

@StrikerRUS
Copy link
Collaborator

StrikerRUS commented Jun 12, 2021

According to this article, you can simply download LightGBM from conda-forge.

LightGBM already has a pre-compiled arm64 version under conda-forge.
https://towardsdatascience.com/install-xgboost-and-lightgbm-on-apple-m1-macs-cb75180a2dda

@fayeshine
Copy link
Author

@StrikerRUS thank you! this link solved my problem. I tested that arm64 version is about 12% faster than x86 version, my train set is about 1000000*1000, num_iteration=10.

@StrikerRUS
Copy link
Collaborator

Very glad you've solved the problem!

this link solved my problem.

Are you referring the article about XGBoost and LightGBM installation?

@fayeshine
Copy link
Author

@StrikerRUS, Yes, I reffered to the article about xgboost and lightgbm installation, this mini-conda package is all compiled in arm64, as well as the lgb package, I know this because it runs in APPLE mode in activity monitor.

As for your question:
'Or could you tell me how to compile with arm64 instruction set on mac, it seems that cmake automatically compile into an intel version.
What makes you think so? Please share the logs here. Also, I believe it worth using the latest CMake.'

Because I can see it runs in INTEL mode in activity monitor of mac, there's no bug during the compilation, so I don't have useful logs. Maybe I need to pass '-DCMAKE_OSX_ARCHITECTURES=arm64' to force cmake compile in arm64 version, but the mini-conda's package works just fine.

@StrikerRUS
Copy link
Collaborator

Thanks a lot the detailed answer!

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants