zoghbi-a / nicer-background

A model for estimating NICER background using Machine Learning
MIT License
5 stars 0 forks source link

Other dependencies #1

Open CraigMarkwardt opened 3 years ago

CraigMarkwardt commented 3 years ago

The code also appears to depend on "xgboost"

It also appears to depend on libomp in a non-trivial way. I think it has a hard-coded path to Homebrew's libomp path.

CraigMarkwardt commented 3 years ago

Here is the runtime error. There are references to "brew install" and /usr/local/opt/libomp/lib/libomp.dylib, which is not where MacPorts installs its version of libomp.

[68]> python3.8
Python 3.8.11 (default, Jul  9 2021, 10:31:44)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> modData = np.load('model.npz',allow_pickle=True)
>>> mod       = modData['mod'][()]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/lib/npyio.py", line 254, in __getitem__
    return format.read_array(bytes,
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/lib/format.py", line 748, in read_array
    array = pickle.load(fp, **pickle_kwargs)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/__init__.py", line 9, in <module>
    from .core import DMatrix, DeviceQuantileDMatrix, Booster
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py", line 195, in <module>
    _LIB = _load_lib()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/core.py", line 178, in _load_lib
    raise XGBoostError(
xgboost.core.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/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib, 6): Library not loaded: /usr/local/opt/libomp/lib/libomp.dylib\n  Referenced from: /opt/local/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/xgboost/lib/libxgboost.dylib\n  Reason: image not found']
zoghbi-a commented 3 years ago

Thanks Craig, I see why it would complain about XGBoost. Does it solve it if XGBoost is installed?

CraigMarkwardt commented 3 years ago

Not installing XGBoost causes a different, earlier error.

Installing XGBoost still leads to the above error.

zoghbi-a commented 3 years ago

I see. The model may need to be saved and read using XGboost. I will try to reproduce the error and work on it. Thanks.

zoghbi-a commented 3 years ago

I was able to reproduce the issue on my mac laptop. It was solved by installing py-xgboost (through pip or conda).

CraigMarkwardt commented 3 years ago

Maybe not pip?

# pip-3.8 install py-xgboost
ERROR: Could not find a version that satisfies the requirement py-xgboost (from versions: none)
ERROR: No matching distribution found for py-xgboost
zoghbi-a commented 3 years ago

It looks like it is a problem with xgboost on mac. It is available only through conda.

The other solution is to install libomp with brew: "brew install libomp" and xgboost with pip. That also solved it for me.

Another option is to try building xgboost from source. https://xgboost.readthedocs.io/en/latest/build.html