-
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
[R-package] R session crashes on Windows when {lightgbm} is loaded after tidyverse #4007
Comments
@estroger34 thanks for using LightGBM! Can you please tell me how you installed You might even be encountering the same issue that the Are you able to reproduce this problem without using |
Came here b/c of similar R session crashing with tidymodels and treesnip. I'm trying @estroger34 examples and for me neither of those worked. Looks like only difference is I'm still on R 3.6.3 R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19041)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] forcats_0.5.1 stringr_1.4.0 readr_1.4.0 tidyverse_1.3.0 treesnip_0.1.0.9000 lightgbm_3.1.1 R6_2.5.0 yardstick_0.0.7 workflows_0.2.1
[10] tune_0.1.2 tidyr_1.1.2 tibble_3.0.6 rsample_0.0.9 recipes_0.1.15 purrr_0.3.4 parsnip_0.1.5 modeldata_0.1.0 infer_0.5.4
[19] ggplot2_3.3.3 dplyr_1.0.4 dials_0.0.9 scales_1.1.1 broom_0.7.5 tidymodels_0.1.2
loaded via a namespace (and not attached):
[1] httr_1.4.2 jsonlite_1.7.2 splines_3.6.3 foreach_1.5.1 prodlim_2019.11.13 modelr_0.1.8 assertthat_0.2.1 GPfit_1.0-8 cellranger_1.1.0 globals_0.14.0
[11] ipred_0.9-9 pillar_1.5.0 backports_1.2.1 lattice_0.20-41 glue_1.4.2 pROC_1.17.0.1 digest_0.6.27 rvest_0.3.6 colorspace_2.0-0 Matrix_1.2-18
[21] plyr_1.8.6 timeDate_3043.102 pkgconfig_2.0.3 lhs_1.1.1 DiceDesign_1.9 listenv_0.8.0 haven_2.3.1 gower_0.2.2 lava_1.6.8.1 generics_0.1.0
[31] tictoc_1.0 ellipsis_0.3.1 withr_2.4.1 furrr_0.2.2 nnet_7.3-15 cli_2.3.0 readxl_1.3.1 survival_3.2-7 magrittr_2.0.1 crayon_1.4.1
[41] fs_1.5.0 future_1.21.0 fansi_0.4.2 parallelly_1.23.0 MASS_7.3-51.6 xml2_1.3.2 class_7.3-18 tools_3.6.3 data.table_1.14.0 hms_1.0.0
[51] lifecycle_1.0.0 reprex_1.0.0 munsell_0.5.0 compiler_3.6.3 tinytex_0.29 rlang_0.4.10 grid_3.6.3 iterators_1.0.13 rstudioapi_0.13 gtable_0.3.0
[61] codetools_0.2-16 DBI_1.1.1 lubridate_1.7.9.2 utf8_1.1.4 stringi_1.5.3 parallel_3.6.3 Rcpp_1.0.6 vctrs_0.3.6 rpart_4.1-15 dbplyr_2.1.0
[71] tidyselect_1.1.0 xfun_0.21 |
thanks for the report! I have the same question for you @z-feldman
|
To test following examples start new R sessions for each... This works: library(lightgbm)
data(agaricus.train, package='lightgbm')
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
model <- lgb.cv(
params = list(
objective = "regression"
, metric = "l2"
)
, data = dtrain
) This crashes: library(tidymodels) # will crash with library(treesnip) or library(tidyverse) instead of {tidymodels}
library(lightgbm)
data(agaricus.train, package='lightgbm')
train <- agaricus.train
dtrain <- lgb.Dataset(train$data, label = train$label)
model <- lgb.cv(
params = list(
objective = "regression"
, metric = "l2"
)
, data = dtrain
) This is also consistent when using treesnip and tidymodels. This works: library(lightgbm)
library(tidymodels)
library(treesnip)
library(tidyverse)
workflow <- workflow() %>%
add_recipe(recipe(formula = Sepal.Length ~ ., data = iris) ) %>%
add_model(boost_tree() %>%
set_mode("regression") %>%
set_engine("lightgbm"))
fit(workflow, data = iris) This crashes: library(tidymodels) # again, if any of the three are loaded before lightgbm it crashes
library(treesnip)
library(lightgbm)
library(tidyverse)
workflow <- workflow() %>%
add_recipe(recipe(formula = Sepal.Length ~ ., data = iris) ) %>%
add_model(boost_tree() %>%
set_mode("regression") %>%
set_engine("lightgbm"))
fit(workflow, data = iris) |
wow that's wild haha! Ok thank you both for the very detailed reproducible examples. I'll look into this as soon as I can. I can rule out one thing, for the benefit of anyone else trying to debug this.
|
Ok I'm testing right now on R 4.0.3, in a fresh R session in a clean container. docker run -it rocker/verse /bin/bash I installed the dependencies you mentioned above. Rscript -e 'remotes::install_github("curso-r/treesnip")'
Rscript -e 'install.packages(c("tidymodels", "tidyverse", "lightgbm"))' I then ran each of the examples from #4007 (comment), even trying each of I created a new session each time by running the following command, which ensures that nothing is being preserved from session to session or read in from config files. R --vanilla --no-restore And I quit each session with Every one of those examples succeeded, and I could not reproduce the crashes. Given this, I don't think there is an issue where Did either of you previously install I'm happy to keep this discussion here so you don't have to bounce back and forth between the projects, but my theory right now is that that non-standard installation with |
I did use rightgbm at one point. I'll try to see if there's something lingering from that |
I did not use rightgbm before. I had installed treesnip just a day before opening this issue. Just now, I removed This leads to exactly the same behaviour as described by @z-feldman on my machine. Now, also the second example of my first post, which did work a few days ago, crashes. Next to re-installing Even the non-treesnip example fails, if
|
I did some more testing and found that in the above non-treesnip example the crash happens with any of the following packages from the
For others, like Rlang, vctrs, generics, magrittr, there is no crash. For the packages causing the crash, it can always be avoided by loading the package after lightgbm. In between the tests, I cleared the environment (incl. hidden objects) in RStudio and restarted the R session. |
I did a little digging on a fresh new windows server machine and I can reproduce the non-treesnip example above. I tried the tidyverse packages individually and also some non-tidyverse packages listed above, below are some results.
Session info below when loading
|
@tonyk7440 or @estroger34 could you try in a non-RStudio R session, like the It's also interesting that all three of you are using Windows. I'll have to try to reproduce this tonight on Windows. |
Hi @jameslamb , just tried what you suggested but unfortunately it also seems to have errored, screenshot attached below |
Ok thanks! That's really helpful. I'm going to change the image title to reflect that. I'm glad we could rule out RStudio as a source of the problem, that would have been really tough to debug 😂 I won't be able to take a look at this until later tonight, but in case anyone gets to it sooner, I have two thoughts that might help.
|
same here. Crashes after treesnip is installed in a clean new vanilla environment in windows 10. All packages are latest version (renv initialized project) treesnip installed with remotes::install_github("curso-r/treesnip") I had to load the packages in this order to make it work:
|
@verajosemanuel This issue has been fixed on Please see #4259 (comment) for steps to install from source and subscribe to #4310 to be notified when a new release is published. |
I'm locking conversation on this issue. Please comment on #4464 if you'd like to join the conversation about this problem. |
I am using lightgbm in a
tidymodels
workflow using the treesnip package. Data loading and wrangling uses functions from thetidyverse
.If
library(lightgbm)
is loaded afterlibrary(tidyverse)
, the R session in RStudio crashes during model fit without further error.If
library(lightgbm)
is loaded beforelibrary(tidyverse)
, this does not happen.This results in a crash:
This works:
I installed lightgbm v3.1.1 from CRAN.
Session info:
The text was updated successfully, but these errors were encountered: