You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We train with GPU on our Linux machine (tree_method='gpu_hist') and pickle dump the model to a json file (xgboost version 1.0.0rc1). Loading the generated model file on a non-GPU machine (MacOS) causes following error: xgboost.core.XGBoostError: [17:35:27] /tmp/pip-install-fjnd8mac/xgboost/xgboost/src/tree/tree_updater.cc:20: Unknown tree updater grow_gpu_hist
When training with CPU only then there is no error and we can load and use the model on e.g. MacOS, as we could before with xgboost version 0.90.
(also enable_experimental_json_serialization = True does not make any difference)
What seems to work is to manually change xgb.get_booster().set_param({'updater':''}) before saving the model file and then change it back to the original value. But I am not sure how this affects the model for sub-sequential runs.
Steps to reproduce:
On the GPU machine:
#!/usr/bin/env python
import xgboost as xgb
from sklearn.datasets import load_boston
import pandas as pd
from sklearn.model_selection import train_test_split
import pickle
import platform
boston = load_boston()
data = pd.DataFrame(boston.data)
data.columns = boston.feature_names
data['PRICE'] = boston.target
print("xgboost version %s on %s" % (xgb.__version__, platform.uname()[0]))
X, y = data.iloc[:,:-1],data.iloc[:,-1]
data_dmatrix = xgb.DMatrix(data=X,label=y)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=123)
xg_reg = xgb.XGBRegressor(objective ='reg:squarederror', n_estimators = 10, tree_method='gpu_hist', enable_experimental_json_serialization = True)
xg_reg.fit(X_train,y_train)
outfile = "test.model.json." + platform.uname()[0]
print("Writing to", outfile)
with open(outfile, 'wb') as fd: pickle.dump(xg_reg, fd)
then transfer the test.model.json.Linux file to MacOS
#!/usr/bin/env python
import xgboost as xgb
import platform
import pickle
print("xgboost version %s on %s" % (xgb.__version__, platform.uname()[0]))
model_file = 'test.model.json.Linux'
print("reading", model_file)
model = pickle.load(open(model_file, 'rb'))
print("Model", model)
The text was updated successfully, but these errors were encountered:
tsp-kucbd
changed the title
"Unknown tree updater grow_gpu_hist" when loading a GPU trained model on a non-GPU machine
[Python] "Unknown tree updater grow_gpu_hist" when loading a GPU trained model on a non-GPU machine
Feb 6, 2020
We train with GPU on our Linux machine (
tree_method='gpu_hist'
) and pickle dump the model to a json file (xgboost version 1.0.0rc1). Loading the generated model file on a non-GPU machine (MacOS) causes following error:xgboost.core.XGBoostError: [17:35:27] /tmp/pip-install-fjnd8mac/xgboost/xgboost/src/tree/tree_updater.cc:20: Unknown tree updater grow_gpu_hist
When training with CPU only then there is no error and we can load and use the model on e.g. MacOS, as we could before with xgboost version 0.90.
(also
enable_experimental_json_serialization = True
does not make any difference)What seems to work is to manually change
xgb.get_booster().set_param({'updater':''})
before saving the model file and then change it back to the original value. But I am not sure how this affects the model for sub-sequential runs.Steps to reproduce:
On the GPU machine:
then transfer the
test.model.json.Linux
file to MacOSThe text was updated successfully, but these errors were encountered: