Segmentation fault occurs when I try to load LightGBM model. I have tried pickle (including protocol change), cloudpickle, joblib, and lightGBM save_model, however, I could not load the models.
Save model:
model = lgb.LGBMRegressor(**kargs)
model.fit(self.X_train, self.y_train)
with open(self.output_dir + 'models.pkl', "wb") as f:
pickle.dump(model, f, protocol=4)
with open(self.output_dir + 'modelcl.pkl', "wb") as f:
f.write(cloudpickle.dumps(model))
pickle.dump(model, open(self.output_dir +
'model.pkl', 'wb'), protocol=4)
joblib.dump(model, f'{self.output_dir}model.joblib')
joblib.dump(model, f'{self.output_dir}model.xz', compress=True)
model.booster_.save_model(f'{self.output_dir}model.txt')
Load model:
joblib.load('path/model.xz')
joblib.load('path/model.joblib')
pickle.load(open('path/models.pkl', 'rb'))
pickle.load(open('path/modelcl.pkl', 'rb'))
pickle.load(open('path/model.pkl', 'rb'))
model = lgb.Booster(model_file='path/model.txt')
Environment: M1 Mac Monterely(12.0.1) Python 3.8.12 (conda), joblib==1.1.0, lightgbm==3.3.2.
Do you have any ideas what is going on here? I think I should try saving the weights instead of saving the entire model, but don't know how on LightGBM.