-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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 while loading model #5826
Comments
Can you share the content of |
@hcho3 I think it would be "easier" to share the model. Without any context to the data, I'm sure I can share the model. The only possible issue is it's 2.9GB. Would the model be helpful?
|
@nathanhack I'd like to see how XGBoost produces a potentially invalid JSON representation, given some data. Do you see the same error with other data? |
@hcho3 I think I see what your getting at. So the weird thing is, the above That said, I'm sure I can give a few samples of input data if you think that will help figure it out. |
@nathanhack In that case, you should upload the model to Dropbox or a similar service and post a link. |
@hcho3 https://file.io/utRYr3SY here's a link to the json file. Note this link will only work one time. If needed again, I can post a new link it just let me know. |
Will look into it. |
@nathanhack I'm getting a 404. |
@hcho3 this link is less ephemeral: https://drive.google.com/file/d/1bRcVE7wnbBhzYliH_9FSDjJMZdtQekBY/view?usp=sharing |
@nathanhack I tried loading the JSON on my machine and did not see any error. I used import xgboost as xgb
param = {
'objective': 'multi:softmax',
'eta': 0.0001,
'max_depth': 6,
'nthread': 16,
'num_class': 2,
'tree_method': 'gpu_hist'
}
bst = xgb.Booster(param)
bst.load_model('xgboostModel.trail04.json')
print(bst) # prints <xgboost.core.Booster object at 0x7f8033025450> |
@hcho3 So. I definitely do not get that, check out my screenshot of pycharm with code you gave. Here are some of my system details: |
How did you install XGBoost? Did you use pip or did you build from the source? |
I used pip. |
@nathanhack So I was using my Macbook (2019, MacOS Catalina) first time. When I ran the same program on a Linux machine (Ubuntu 18.04 LTS), it actually produced the same error
This is strange, since the Mac and Linux binaries have been built using the same source. I will investigate further. |
The error exists with the latest source too. Stacktrace:
|
I found the root cause: Lines 111 to 128 in e4f5b6c
We use POSIX functions to load the JSON file into memory, and there is a bug that introduces NUL letters (value 0) into the string. I'm trying to diagnose the bug. The different behavior between Linux and MacOS is explained: on MacOS, |
@nathanhack I submitted a pull request to fix the bug: #5831. It will be part of the next upcoming release (1.2.0). Thanks! |
Thanks for the thorough investigation of my issue, and for the quick fix! |
After train a model for a long time I saved it using
bst.save_model("xgboostModel.trail04.json")
I latter tried to load it with the same params to continue training
but I get this error:
When I try the same exact thing but run it over a smaller number of rounds it loads fine and trains like a champ.
The text was updated successfully, but these errors were encountered: