Fatal Error when Training on DMatrix from Loaded R Workspace
I load an R Workspace into RStudio on Windows 64-bit. The workspace contains DMatrices that I've saved from a previous session. When I train an xgboost model on this (e.g., xgb.train() or xgb.cv()), R-Studio crashes and forces me to restart.
Error message with popup window: "R encountered a fatal error. The session was terminated."
So I have to start a new session. I have not been able to successfully load a workspace with DMatrices.
Thanks!
I also have this problem - my dataset is 480k rows and 200 columns, could this be a factor in causing xgboost to crash?
DMatrices are not directly managed by R session but by the xgboost shared library. R session basically knows about a pointer to a DMatrix - like a remote - through which you can handle it. Saving a workspace would save that pointer but not the data in memory it points to. After loading, it would most likely point to a NULL address - thus the crashes. The responsibility of saving and loading DMatrices is on user.
I would be glad to be proven wrong, but I don't know of any direct way to make R to handle external objects as its own. Some ugly specific workarounds, I guess, might be possible. But why resort to that for a little convenience?
@khotilov I don't understand your answer perfectly. Sorry for my knowledge :( What makes this fatal error? Don't use save() and load()? Use xgb.train() or xgb.cv() right after making the train set?
I am having the same issue. When I am going to train xgb.train, my r session aborted. I am not able to find the solution anywhere. Any suggestion will be appreciated.
@vini-akki Save data as xgbDMatrix format by R command xgb.DMatrix.save() of package xgboost. Then rm(list=ls()). Then restart R. Then library(xgboost). Finally, load xgbDMatrix by R command xgb.DMatrix(). It might help you a littele.
data(agaricus.train, package='xgboost')
train <- agaricus.train
dtrain <- xgb.DMatrix(train$data, label=train$label)
xgb.DMatrix.save(dtrain, 'xgb.DMatrix.data')
rm(list = ls())
#restart R
library(xgboost)
dtrain <- xgb.DMatrix('xgb.DMatrix.data')