Parallel computation on Windows
Closed this issue · 8 comments
I'm trying to parallelize my computation (on Windows 10 machine) but without success. I always get the same error.
library(tidymodels)
library(rules)
library(tidymodels)
library(future)
library(doFuture)
mt_train <- mtcars[1:25,]
mt_test <- mtcars[26:32,]
recipe_mt <- recipe(mpg ~ ., data = mt_train)
# Model spec
model_spec_cubist <- cubist_rules(
committees = 100,
neighbors = 3,
max_rules = 100
) %>%
set_engine("Cubist")
# Workflow
wflw <- workflow() %>%
add_model(model_spec_cubist) %>%
add_recipe(recipe_mt) %>%
fit(mt_train)
# Tune
model_spec <- cubist_rules(
mode = "regression",
committees = tune(),
neighbors = tune(),
max_rules = tune()
) %>%
set_engine("Cubist")
grid_spec <- grid_latin_hypercube(
parameters(model_spec),
size = 10
)
# Update workflow
wflw <- wflw %>%
update_model(model_spec)
resamples <- vfold_cv(
data = mtcars,
v = 5,
repeats = 5
)
registerDoFuture()
n_cores <- detectCores()
plan(
strategy = cluster,
workers = parallel::makeCluster(n_cores)
)
set.seed(123)
tune_results <- wflw %>%
tune_grid(
resamples = resamples,
grid = grid_spec,
# metrics = default_forecast_accuracy_metric_set(),
metrics = metric_set(rmse, rsq),
control = control_grid(verbose = FALSE, save_pred = TRUE)
)
plan(strategy = sequential)
Results in:
x Fold1, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is missing, with no default
Warning message:
All models failed in tune_grid(). See the `.notes` column.
for all the folds.
Can you tell us the versions of everything (or use reprex::reprex(si = TRUE)
)?
reprex::reprex(si = TRUE)
#> No input provided and clipboard is not available.
#> Rendering reprex...
Created on 2020-09-25 by the reprex package (v0.3.0)
Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.0.2 (2020-06-22)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Icelandic_Iceland.1252
#> ctype Icelandic_Iceland.1252
#> tz Africa/Casablanca
#> date 2020-09-25
#>
#> - Packages -------------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
#> backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
#> callr 3.4.4 2020-09-07 [1] CRAN (R 4.0.2)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
#> clipr 0.7.0 2019-07-23 [1] CRAN (R 4.0.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
#> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.2)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
#> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0)
#> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
#> knitr 1.29 2020-06-23 [1] CRAN (R 4.0.2)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
#> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
#> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
#> ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> reprex 0.3.0 2019-05-16 [1] CRAN (R 4.0.0)
#> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
#> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
#> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
#> tibble 3.0.3 2020-07-10 [1] CRAN (R 4.0.2)
#> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.2)
#> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
#> whisker 0.4 2019-08-28 [1] CRAN (R 4.0.0)
#> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)
#> xfun 0.17 2020-09-09 [1] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
#>
#> [1] C:/Users/vidar/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library
Sorry, I should have been more clear. Copy your analysis code to the clipboard and run reprex::reprex(si = TRUE)
Sorry, my bad. Here it is.
library(tidymodels)
#> -- Attaching packages ----------------------------------------------------------- tidymodels 0.1.1 --
#> v broom 0.7.0 v recipes 0.1.13.9001
#> v dials 0.0.9.9000 v rsample 0.0.8.9000
#> v dplyr 1.0.2 v tibble 3.0.3
#> v ggplot2 3.3.2 v tidyr 1.1.2
#> v infer 0.5.3 v tune 0.1.1.9000
#> v modeldata 0.0.2 v workflows 0.2.0.9000
#> v parsnip 0.1.3.9000 v yardstick 0.0.7
#> v purrr 0.3.4
#> -- Conflicts -------------------------------------------------------------- tidymodels_conflicts() --
#> x purrr::discard() masks scales::discard()
#> x dplyr::filter() masks stats::filter()
#> x dplyr::lag() masks stats::lag()
#> x recipes::step() masks stats::step()
library(rules)
#>
#> Attaching package: 'rules'
#> The following object is masked from 'package:dials':
#>
#> max_rules
library(tidymodels)
library(future)
library(doFuture)
#> Loading required package: foreach
#>
#> Attaching package: 'foreach'
#> The following objects are masked from 'package:purrr':
#>
#> accumulate, when
library(parallel)
mt_train <- mtcars[1:25,]
mt_test <- mtcars[26:32,]
recipe_mt <- recipe(mpg ~ ., data = mt_train)
# Model spec
model_spec_cubist <- cubist_rules(
committees = 100,
neighbors = 3,
max_rules = 100
) %>%
set_engine("Cubist")
# Workflow
wflw <- workflow() %>%
add_model(model_spec_cubist) %>%
add_recipe(recipe_mt) %>%
fit(mt_train)
# Tune
model_spec <- cubist_rules(
mode = "regression",
committees = tune(),
neighbors = tune(),
max_rules = tune()
) %>%
set_engine("Cubist")
grid_spec <- grid_latin_hypercube(
parameters(model_spec),
size = 10
)
# Update workflow
wflw <- wflw %>%
update_model(model_spec)
resamples <- vfold_cv(
data = mtcars,
v = 5,
repeats = 5
)
registerDoFuture()
n_cores <- detectCores()
plan(
strategy = cluster,
workers = parallel::makeCluster(n_cores)
)
set.seed(123)
tune_results <- wflw %>%
tune_grid(
resamples = resamples,
grid = grid_spec,
# metrics = default_forecast_accuracy_metric_set(),
metrics = metric_set(rmse, rsq),
control = control_grid(verbose = FALSE, save_pred = TRUE)
)
#> x Fold1, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold2, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold3, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold4, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold5, Repeat1: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold1, Repeat2: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold2, Repeat2: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold3, Repeat2: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold4, Repeat2: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold5, Repeat2: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold1, Repeat3: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold2, Repeat3: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold3, Repeat3: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold4, Repeat3: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold5, Repeat3: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold1, Repeat4: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold2, Repeat4: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold3, Repeat4: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold4, Repeat4: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold5, Repeat4: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold1, Repeat5: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold2, Repeat5: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold3, Repeat5: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold4, Repeat5: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> x Fold5, Repeat5: internal: Error in rlang::env_get(mod_env, items): argument "default" is...
#> Warning: All models failed in tune_grid(). See the `.notes` column.
plan(strategy = sequential)
Created on 2020-09-29 by the reprex package (v0.3.0)
Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#> setting value
#> version R version 4.0.2 (2020-06-22)
#> os Windows 10 x64
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate Icelandic_Iceland.1252
#> ctype Icelandic_Iceland.1252
#> tz Africa/Casablanca
#> date 2020-09-29
#>
#> - Packages -------------------------------------------------------------------
#> package * version date lib source
#> assertthat 0.2.1 2019-03-21 [1] CRAN (R 4.0.0)
#> backports 1.1.10 2020-09-15 [1] CRAN (R 4.0.2)
#> broom * 0.7.0 2020-07-09 [1] CRAN (R 4.0.2)
#> callr 3.4.4 2020-09-07 [1] CRAN (R 4.0.2)
#> class 7.3-17 2020-04-26 [1] CRAN (R 4.0.2)
#> cli 2.0.2 2020-02-28 [1] CRAN (R 4.0.0)
#> codetools 0.2-16 2018-12-24 [1] CRAN (R 4.0.0)
#> colorspace 1.4-1 2019-03-18 [1] CRAN (R 4.0.0)
#> crayon 1.3.4 2017-09-16 [1] CRAN (R 4.0.0)
#> Cubist 0.2.3 2020-01-10 [1] CRAN (R 4.0.0)
#> desc 1.2.0 2018-05-01 [1] CRAN (R 4.0.0)
#> devtools 2.3.2 2020-09-18 [1] CRAN (R 4.0.2)
#> dials * 0.0.9.9000 2020-09-24 [1] Github (tidymodels/dials@2b79300)
#> DiceDesign 1.8-1 2019-07-31 [1] CRAN (R 4.0.0)
#> digest 0.6.25 2020-02-23 [1] CRAN (R 4.0.0)
#> doFuture * 0.10.0 2020-09-24 [1] CRAN (R 4.0.2)
#> dplyr * 1.0.2 2020-08-18 [1] CRAN (R 4.0.2)
#> ellipsis 0.3.1 2020-05-15 [1] CRAN (R 4.0.2)
#> evaluate 0.14 2019-05-28 [1] CRAN (R 4.0.0)
#> fansi 0.4.1 2020-01-08 [1] CRAN (R 4.0.0)
#> foreach * 1.5.0 2020-03-30 [1] CRAN (R 4.0.0)
#> fs 1.5.0 2020-07-31 [1] CRAN (R 4.0.2)
#> furrr 0.1.0 2018-05-16 [1] CRAN (R 4.0.0)
#> future * 1.19.1 2020-09-22 [1] CRAN (R 4.0.2)
#> generics 0.0.2 2018-11-29 [1] CRAN (R 4.0.0)
#> ggplot2 * 3.3.2 2020-06-19 [1] CRAN (R 4.0.2)
#> globals 0.13.0 2020-09-17 [1] CRAN (R 4.0.2)
#> glue 1.4.2 2020-08-27 [1] CRAN (R 4.0.2)
#> gower 0.2.2 2020-06-23 [1] CRAN (R 4.0.2)
#> GPfit 1.0-8 2019-02-08 [1] CRAN (R 4.0.0)
#> gtable 0.3.0 2019-03-25 [1] CRAN (R 4.0.0)
#> hardhat 0.1.4 2020-07-02 [1] CRAN (R 4.0.2)
#> highr 0.8 2019-03-20 [1] CRAN (R 4.0.0)
#> htmltools 0.5.0 2020-06-16 [1] CRAN (R 4.0.2)
#> infer * 0.5.3 2020-07-14 [1] CRAN (R 4.0.2)
#> ipred 0.9-9 2019-04-28 [1] CRAN (R 4.0.0)
#> iterators 1.0.12 2019-07-26 [1] CRAN (R 4.0.0)
#> knitr 1.30 2020-09-22 [1] CRAN (R 4.0.2)
#> lattice 0.20-41 2020-04-02 [1] CRAN (R 4.0.0)
#> lava 1.6.8 2020-09-26 [1] CRAN (R 4.0.2)
#> lhs 1.0.2 2020-04-13 [1] CRAN (R 4.0.0)
#> lifecycle 0.2.0 2020-03-06 [1] CRAN (R 4.0.0)
#> listenv 0.8.0 2019-12-05 [1] CRAN (R 4.0.0)
#> lubridate 1.7.9 2020-06-08 [1] CRAN (R 4.0.2)
#> magrittr 1.5 2014-11-22 [1] CRAN (R 4.0.0)
#> MASS 7.3-53 2020-09-09 [1] CRAN (R 4.0.2)
#> Matrix 1.2-18 2019-11-27 [1] CRAN (R 4.0.0)
#> memoise 1.1.0 2017-04-21 [1] CRAN (R 4.0.0)
#> modeldata * 0.0.2 2020-06-22 [1] CRAN (R 4.0.2)
#> munsell 0.5.0 2018-06-12 [1] CRAN (R 4.0.0)
#> nnet 7.3-14 2020-04-26 [1] CRAN (R 4.0.2)
#> parsnip * 0.1.3.9000 2020-09-16 [1] Github (tidymodels/parsnip@cf62381)
#> pillar 1.4.6 2020-07-10 [1] CRAN (R 4.0.2)
#> pkgbuild 1.1.0 2020-07-13 [1] CRAN (R 4.0.2)
#> pkgconfig 2.0.3 2019-09-22 [1] CRAN (R 4.0.0)
#> pkgload 1.1.0 2020-05-29 [1] CRAN (R 4.0.2)
#> plyr 1.8.6 2020-03-03 [1] CRAN (R 4.0.0)
#> prettyunits 1.1.1 2020-01-24 [1] CRAN (R 4.0.0)
#> pROC 1.16.2 2020-03-19 [1] CRAN (R 4.0.0)
#> processx 3.4.4 2020-09-03 [1] CRAN (R 4.0.2)
#> prodlim 2019.11.13 2019-11-17 [1] CRAN (R 4.0.0)
#> ps 1.3.4 2020-08-11 [1] CRAN (R 4.0.2)
#> purrr * 0.3.4 2020-04-17 [1] CRAN (R 4.0.0)
#> R6 2.4.1 2019-11-12 [1] CRAN (R 4.0.0)
#> Rcpp 1.0.5 2020-07-06 [1] CRAN (R 4.0.2)
#> recipes * 0.1.13.9001 2020-09-16 [1] Github (tidymodels/recipes@c9b9987)
#> remotes 2.2.0 2020-07-21 [1] CRAN (R 4.0.2)
#> reshape2 1.4.4 2020-04-09 [1] CRAN (R 4.0.0)
#> rlang 0.4.7 2020-07-09 [1] CRAN (R 4.0.2)
#> rmarkdown 2.3 2020-06-18 [1] CRAN (R 4.0.2)
#> rpart 4.1-15 2019-04-12 [1] CRAN (R 4.0.0)
#> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 4.0.0)
#> rsample * 0.0.8.9000 2020-09-24 [1] Github (tidymodels/rsample@ae99c86)
#> rstudioapi 0.11 2020-02-07 [1] CRAN (R 4.0.0)
#> rules * 0.0.2 2020-06-10 [1] CRAN (R 4.0.2)
#> scales * 1.1.1 2020-05-11 [1] CRAN (R 4.0.2)
#> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 4.0.0)
#> stringi 1.5.3 2020-09-09 [1] CRAN (R 4.0.2)
#> stringr 1.4.0 2019-02-10 [1] CRAN (R 4.0.0)
#> survival 3.2-3 2020-06-13 [1] CRAN (R 4.0.2)
#> testthat 2.3.2 2020-03-02 [1] CRAN (R 4.0.0)
#> tibble * 3.0.3 2020-07-10 [1] CRAN (R 4.0.2)
#> tidymodels * 0.1.1 2020-07-14 [1] CRAN (R 4.0.2)
#> tidyr * 1.1.2 2020-08-27 [1] CRAN (R 4.0.2)
#> tidyselect 1.1.0 2020-05-11 [1] CRAN (R 4.0.2)
#> timeDate 3043.102 2018-02-21 [1] CRAN (R 4.0.0)
#> tune * 0.1.1.9000 2020-09-24 [1] Github (tidymodels/tune@addcbe8)
#> usethis 1.6.3 2020-09-17 [1] CRAN (R 4.0.2)
#> vctrs 0.3.4 2020-08-29 [1] CRAN (R 4.0.2)
#> withr 2.3.0 2020-09-22 [1] CRAN (R 4.0.2)
#> workflows * 0.2.0.9000 2020-09-24 [1] Github (tidymodels/workflows@213d4cd)
#> xfun 0.17 2020-09-09 [1] CRAN (R 4.0.2)
#> yaml 2.2.1 2020-02-01 [1] CRAN (R 4.0.0)
#> yardstick * 0.0.7 2020-07-13 [1] CRAN (R 4.0.2)
#>
#> [1] C:/Users/vidar/Documents/R/win-library/4.0
#> [2] C:/Program Files/R/R-4.0.2/library
Thanks. I'm see this too.
I tune
, we fixed an issue where the parsnip
add-on packages were not loading in the remote workers. This seems to be the same problem (but confined to the GH version of tune
).
I'll look further.
Can you try with:
remotes::install_dev("rules")
I think that there were changes that went with the tune
changes. It worked here for devel tune
and rules
.
This worked :)
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.