这基本上与此How to set .libPaths (checkpoint) on workers when running parallel computation in R相同,但现在解决了mlr模型拟合的并行化问题。我了解我需要将parallelMap
与mlr
一起使用,但是如何确保每个工作人员都使用正确的.libPaths
?
remove.packages("mlr")
remove.packages("rpart")
checkpoint::checkpoint("2018-09-01",
scanForPackages = TRUE)
library(mlr)
library(parallelMap)
library(rpart)
parallelStartSocket(2L)
task = makeClassifTask(data = iris, target = "Species")
learner = makeLearner("classif.rpart", minsplit = 7, predict.type = "prob")
mod = resample(learner, task, resampling = cv5)
parallelStop()
parallelLibrary(“ mlr”,master = FALSE,级别= “ mlr.resample” ,:不能在所有从站上加载程序包:mlr。
会话信息:
R版本3.5.1(2018-07-02)平台:x86_64-w64-mingw32 / x64(64位) 在以下环境中运行:Windows 7 x64(内部版本7601)Service Pack 1
Matrix产品:默认
语言环境:[1] LC_COLLATE = German_Germany.1252 LC_CTYPE =德语_德国.1252 LC_MONETARY =德语_德国.1252 [4] LC_NUMERIC = C LC_TIME = German_Germany.1252
附加的基本软件包:[1]统计图形grDevices utils
数据集方法基础其他附加软件包:[1] rpart_4.1-13 parallelMap_1.3
mlr_2.13 ParamHelpers_1.11通过名称空间(未附加)加载:[1] Rcpp_0.12.18
支柱_1.3.0编译器_3.5.1 plyr_1.8.4绑定器_0.1.1
tools_3.5.1 [7] tibble_1.4.2 gtable_0.2.0
checkmate_1.8.5格子_0.20-35 pkgconfig_2.0.2 rlang_0.2.2
[13] Matrix_1.2-14 fastmatch_1.1-0 rstudioapi_0.7 yaml_2.2.0 parallel_3.5.1 bindrcpp_0.2.2 [19] dplyr_0.7.6 grid_3.5.1 tidyselect_0.2.4胶水_1.3.0 data.table_1.11.4 R6_2.2.2
[25] XML_3.98-1.16 Survival_2.42-3 ggplot2_3.0.0 purrr_0.2.5 magrittr_1.5 backports_1.1.2 [31]标度_1.0.0 BBmisc_1.11 splines_3.5.1断言_0.2.0检查点_0.4.3 colorspace_1.3-2 [37] stringi_1.1.7 lazyeval_0.2.1 munsell_0.5.0
crayon_1.3.4
答案 0 :(得分:0)
如果我使用R_LIBS将默认库路径更改为检查点目录,则对我有用。
remove.packages("mlr")
remove.packages("rpart")
print(.libPaths())
checkpoint::checkpoint("2018-09-01",
scanForPackages = TRUE)
print(.libPaths())
Sys.setenv(R_LIBS = paste(.libPaths()[1], Sys.getenv("R_LIBS"), sep = .Platform$path.sep))
library(mlr)
library(parallelMap)
library(rpart)
parallelStartSocket(2L)
task = makeClassifTask(data = iris, target = "Species")
learner = makeLearner("classif.rpart", minsplit = 7, predict.type = "prob")
mod = resample(learner, task, resampling = cv5)
parallelStop()