piwheels / packages

Issue tracker for piwheels package issues
https://github.com/piwheels/packages/issues
20 stars 5 forks source link

Fail to load xgboost model on Raspberry Pi (model previously trained on laptop) #179

Closed saramasarone closed 3 years ago

saramasarone commented 3 years ago

Package name: xgboost Issue type: Fail to load xgboost (Json) model Link to PyPI page: // Link to piwheels page: https://www.piwheels.org/project/xgboost/ Version: 1.3.1 Python version: 3.7.3 I am the maintainer: No More information:

Hi, I get an error when trying to execute this script on raspberry pi3b. The model I am trying to load here was previously trained and saved (model.save()) as a Json file on Python 3.7.5 The training was done on my laptop (macOS). I copied my script below with the error trace I get.

my script:

import xgboost as xgb
import pandas as pd
import numpy as np

#load new data (dir to be checked)
new_data = pd.read_csv('example_data1.csv',header = 0, index_col=0)
bst = xgb.Booster({'nthread': 4})  # init model
bst.load_model('xgb_model_rpy.json')

#convert new data
dmatrix = xgb.DMatrix(new_data.T)
print(bst.predict(dmatrix))

Error trace:

Traceback (most recent call last):
  File "xgb_rpy.py", line 8, in <module>
    bst.load_model('xgb_model_rpy.json')
  File "/home/pi/.local/lib/python3.7/site-packages/xgboost/core.py", line 1729, in load_model
    self.handle, c_str(os.fspath(fname))))
  File "/home/pi/.local/lib/python3.7/site-packages/xgboost/core.py", line 189, in _check_call
    raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: [13:18:49] /tmp/pip-wheel-k9d9tngc/xgboost/build/temp.linux-armv7l-3.7/xgboost/src/c_api/c_api.cc:623: Check failed: str[0] == '{' (

Is there a workaround for this? (xgboost was installed using Pi wheels as suggested on the docs.)

bennuttall commented 3 years ago

Sorry this is not the place for issues using libraries, we just build wheels and host them. This issue tracker is for missing packages or issues related to piwheels.org not the libraries themselves - you'll have to take it up with the proect maintainers or try the Rapsberry Pi forum. piwheels helped you install it quickly but that's as far as we go :)

saramasarone commented 3 years ago

I'll post it there! Thank you