Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when importing XGBoost on Apple M1?

Tags:

Has anyone figured out how to make XGboost work with Apple M1?

I have tried multiple things to fix it, but it does not work.

I have tried reinstalling it; pip and pip3 and python -m pip and conda install; brew install limpomp; brew install gcc@8; Downloading source code and compiling locally.

It seems XGboost does not work on Apple M1.

Here is the error, this occurs when I import xgboost in my script:

XGBoostError: XGBoost Library (libxgboost.dylib) could not be loaded.
Likely causes:
  * OpenMP runtime is not installed (vcomp140.dll or libgomp-1.dll for Windows, libomp.dylib for Mac OSX, libgomp.so for Linux and other UNIX-like OSes). Mac OSX users: Run `brew install libomp` to install OpenMP runtime.
  * You are running 32-bit Python on a 64-bit OS
Error message(s): ['dlopen(/opt/anaconda3/envs/msc-env/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n  Referenced from: /opt/anaconda3/envs/msc-env/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n  Reason: image not found']
like image 495
Rudzani Mulaudzi Avatar asked Jan 16 '21 17:01

Rudzani Mulaudzi


1 Answers

i'd got the same issue on MacBook Pro (13-inch, M1, 2020) with chip Apple M1, fortunately after of hours of some researches i got the solution, you just follow the following instruction:

brew install libomp
conda install -c conda-forge py-xgboost
like image 148
borsaid Avatar answered Sep 25 '22 01:09

borsaid