-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Error training model: Negative size passed to PyBytes_FromStringAndSize #1598
Comments
It seems the string length exceed the range of 32-bit integer. Please consider the smaller num_leaves. |
@guolinke Unfortunately the performance of the model reduces with reduction in num_leaves. The best performance was achieved with the same params with nrounds=800 on R. Do you think there is a workaround to this issue by tweaking the datatype of the string? |
@asindus you can try to set `keep_training_booster=True' in https://lightgbm.readthedocs.io/en/latest/Python-API.html#lightgbm.train. |
@guolinke Thanks, seems to work with `keep_training_booster=True'. However, comparing the output of R and Python models with same parameters, I'm getting considerably different performance on test data. MAPE R: 16% vs MAPE Python: 22%. Any reason why this should happen? The features are all numerical and do not contains any null/ Inf values. |
@guolinke fix or FAQ? |
Sorry for missing this issue. |
@guolinke Oh, I didn't notice that this issue contains actually two problems. I was interesting about model string length limit. |
@StrikerRUS From the code, I think the string length constraints was fixed: https://github.com/Microsoft/LightGBM/blob/master/python-package/lightgbm/basic.py#L2062 |
@guolinke While working on reproducing this issue I've encountered As you can see, it's a Warning. Shouldn't it be Fatal? Unfortunately, search over the sources with "bad allocation" gave nothing. |
@StrikerRUS Throwing exceptions inside openmp loop will crash. Maybe we need a new key word for errors inside omp loop, like "OMP Loop Fatal" or something similar. |
@guolinke Ah, got it! Unfortunately, there was no error after these warnings
In case of Jupyter Notebook a lot of warnings are printed and then kernel dies without exception: Ordinary Python script doesn't produce any exception in the end too: |
I guess some errors will crash directly before backing to main thread. |
ping @asindus |
@guolinke @StrikerRUS Unfortunaley, I no longer have access to the environment (and data) where this error was encountered so replication of the error would be quite tricky (also finding the version of LightGBM). If it helps, the package was installed using "pip3 install lightgbm" on the Ubuntu environment listed above. |
@StrikerRUS |
@guolinke Fair and good point! |
@guolinke I think we can train on one dataset from examples, save and upload in the repo some huge LightGBM model. And at CI side only load it and try to predict to save the CI time. |
@StrikerRUS will the size of this model too large? |
@guolinke Hmm... Very likely. What size do we need? |
yeah, I think it is a good idea. |
@guolinke I'm afraid we will hit the RAM limit with such big string at CI side. For example, Travis' macOS has 4GB: https://docs.travis-ci.com/user/reference/overview/#virtualisation-environment-vs-operating-system. |
@StrikerRUS maybe we can do the test only in Linux? |
Hi the lof [201904.28 093411_log.txt] show the activity till the crash (https://github.com/Microsoft/LightGBM/files/3127233/201904.28.093411_log.txt) My Console output:
|
Operating System: Ubuntu 16.04
AWS EC2 Instance : r5.24xlarge(vcpu: 96 , Memory: 768 GB)
Train Shape: 89M rows, 224 features
Error message
Traceback (most recent call last):
File "Model_run.py", line 336, in
lgbmodel = lgb.train(params, train_lgb)
File "/usr/local/lib/python3.5/dist-packages/lightgbm/engine.py", line 228, in train
booster._load_model_from_string(booster._save_model_to_string(), False)
File "/usr/local/lib/python3.5/dist-packages/lightgbm/basic.py", line 1719, in _save_model_to_string
return string_buffer.value.decode()
SystemError: Negative size passed to PyBytes_FromStringAndSize
Parameters
params = {
'objective': 'mape',
'metric': 'mape',
'boosting': 'gbdt',
'learning_rate': 0.012,
'verbose': 0,
'num_leaves': 150000,
'bagging_freq': 0,
'min_data_in_leaf': 300,
'max_bin': 255,
'max_depth': 28,
'num_rounds': 200,
'min_gain_to_split': 0.0,
'save_binary': True
}
Python3: Model is generated successfully with nrounds=100.
PS: The same parameters (with nrounds=200) successfully yield a model object in R.
The text was updated successfully, but these errors were encountered: