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

xgboost on OSX #306

Open
mdeceglie opened this issue Dec 9, 2021 · 4 comments
Open

xgboost on OSX #306

mdeceglie opened this issue Dec 9, 2021 · 4 comments

Comments

@mdeceglie
Copy link
Collaborator

Describe the bug
Importing rdtools causes an error on mac when everything has been installed with pip

Full error message and traceback

---------------------------------------------------------------------------
XGBoostError                              Traceback (most recent call last)
<ipython-input-1-1cb1b3438ad7> in <module>()
      3 import numpy as np
      4 import pvlib
----> 5 import rdtools
      6 get_ipython().magic('matplotlib inline')

/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/rdtools/__init__.py in <module>()
     10 from rdtools.aggregation import aggregation_insol
     11 from rdtools.clearsky_temperature import get_clearsky_tamb
---> 12 from rdtools.filtering import csi_filter
     13 from rdtools.filtering import poa_filter
     14 from rdtools.filtering import tcell_filter

/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/rdtools/filtering.py in <module>()
      8 from numbers import Number
      9 import rdtools
---> 10 import xgboost as xgb
     11 
     12 # Load in the XGBoost clipping model using joblib.

/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/xgboost/__init__.py in <module>()
      7 import os
      8 
----> 9 from .core import DMatrix, DeviceQuantileDMatrix, Booster, DataIter
     10 from .training import train, cv
     11 from . import rabit  # noqa

/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/xgboost/core.py in <module>()
    201 
    202 # load the XGBoost library globally
--> 203 _LIB = _load_lib()
    204 
    205 

/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/xgboost/core.py in _load_lib()
    192 
    193 Error message(s): {os_error_list}
--> 194 """)
    195     lib.XGBGetLastError.restype = ctypes.c_char_p
    196     lib.callback = _get_log_callback_func()

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(/Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n  Referenced from: /Users/mdecegli/opt/anaconda3/envs/xgboost/lib/python3.7/site-packages/xgboost/lib/libxgboost.dylib\n  Reason: image not found']

To Reproduce
Install rdtools using pip on osx

Expected behavior
Import successful

possible solution
The error can be avoided by installing xgboost with conda. Perhaps we can catch the error and offer that suggestion.

@mikofski
Copy link
Contributor

mikofski commented Dec 9, 2021

https://xgboost.readthedocs.io/en/stable/build.html#building-on-macos

brew install libomp? See dmlc/xgboost#4477 (comment)

@kandersolar
Copy link
Member

The error can be avoided by installing xgboost with conda. Perhaps we can catch the error and offer that suggestion.

What would our message have that isn't already in xgboost's? I'm inclined to let the xgboost error message speak for itself (as @mikofski points out, it already says Mac OSX users: Run `brew install libomp` to install OpenMP runtime.), unless you think installing from conda is better?

@mdeceglie
Copy link
Collaborator Author

Conda is easier IMO, our users are more likely to already have conda and not necessarily brew. And while brew is supposed to be nice, it always proves painful for me because of some combination of administrative privileges and company VPN certificate errors. There's also a lot of love for the conda option in the issue @mikofski linked, I'm surprised that isn't also suggested by the xgboost error message, so I suggest we add it.

I also think we should consider moving the import to the function. This may be worth ignoring pep8.

@kandersolar
Copy link
Member

I did something similar for pvfactors with shapely and lgeos, maybe helpful: SunPower/pvfactors#110

I also think we should consider moving the import to the function. This may be worth ignoring pep8.

In that case we might be able to make xgboost, scikit-learn, and joblib optional like how pvlib has pip install pvlib[optional]: https://github.com/pvlib/pvlib-python/blob/master/setup.py#L55-L58

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants