LightGBM: [R-package] R session crashes on Windows when {lightgbm} is loaded after tidyverse

I am using lightgbm in a tidymodels workflow using the treesnip package. Data loading and wrangling uses functions from the tidyverse.

If library(lightgbm) is loaded after library(tidyverse), the R session in RStudio crashes during model fit without further error.

If library(lightgbm) is loaded before library(tidyverse), this does not happen.

This results in a crash:

library(tidyverse)

library(tidymodels)
library(lightgbm)
library(treesnip)

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 works:

library(tidymodels)
library(lightgbm)
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)

I installed lightgbm v3.1.1 from CRAN.

Session info:

R version 4.0.3 (2020-10-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           
[5] LC_TIME=English_United Kingdom.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
 [6] lightgbm_3.1.1      R6_2.5.0            yardstick_0.0.7     workflows_0.2.1     tune_0.1.2         
[11] tidyr_1.1.2         tibble_3.0.6        rsample_0.0.9       recipes_0.1.15      purrr_0.3.4        
[16] parsnip_0.1.5       modeldata_0.1.0     infer_0.5.4         ggplot2_3.3.3       dplyr_1.0.4        
[21] dials_0.0.9         scales_1.1.1        broom_0.7.4         tidymodels_0.1.2   

loaded via a namespace (and not attached):
 [1] httr_1.4.2         jsonlite_1.7.2     splines_4.0.3      foreach_1.5.1      modelr_0.1.8       prodlim_2019.11.13
 [7] vip_0.3.2          assertthat_0.2.1   GPfit_1.0-8        cellranger_1.1.0   globals_0.14.0     ipred_0.9-9       
[13] pillar_1.4.7       backports_1.2.1    lattice_0.20-41    glue_1.4.2         pROC_1.17.0.1      digest_0.6.27     
[19] hardhat_0.1.5      rvest_0.3.6        snakecase_0.11.0   colorspace_2.0-0   Matrix_1.2-18      plyr_1.8.6        
[25] timeDate_3043.102  pkgconfig_2.0.3    lhs_1.1.1          DiceDesign_1.9     listenv_0.8.0      haven_2.3.1       
[31] gower_0.2.2        lava_1.6.8.1       generics_0.1.0     tictoc_1.0         ellipsis_0.3.1     withr_2.4.1       
[37] janitor_2.1.0      furrr_0.2.2        nnet_7.3-14        cli_2.3.0          readxl_1.3.1       survival_3.2-7    
[43] magrittr_2.0.1     crayon_1.4.1       fs_1.5.0           future_1.21.0      parallelly_1.23.0  MASS_7.3-53       
[49] xml2_1.3.2         class_7.3-17       tools_4.0.3        data.table_1.13.6  hms_1.0.0          lifecycle_1.0.0   
[55] reprex_1.0.0       munsell_0.5.0      compiler_4.0.3     tinytex_0.29       rlang_0.4.10       grid_4.0.3        
[61] iterators_1.0.13   rstudioapi_0.13    gtable_0.3.0       codetools_0.2-16   DBI_1.1.1          gridExtra_2.3     
[67] lubridate_1.7.9.2  stringi_1.5.3      parallel_4.0.3     Rcpp_1.0.6         vctrs_0.3.6        rpart_4.1-15      
[73] dbplyr_2.1.0       tidyselect_1.1.0   xfun_0.21         

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Hi @jameslamb , just tried what you suggested but unfortunately it also seems to have errored, screenshot attached below I noticed too that all the examples are using Windows, I think I’ve had this problem with a while but just put it down to my own little computer problem

image