【发布时间】:2021-08-15 17:42:47
【问题描述】:
我正在迁移到一个新的 Azure 虚拟机,突然在我以前从未遇到过的疯狂地方出现崩溃和错误。 (新的虚拟机是从 Windows Server 2016 切换到 2019 的,但这可能是一个完全的红鲱鱼。)我已经找到了一个可以使用以下代码重现问题的地方
# load packages
library(foreach)
library(randomForest)
library(iterators)
library(parallel)
library(doParallel)
numCores <- detectCores() - 1
ntrees <- 8000
treeSubs <- ntrees/numCores
# initialize
cl <- makeCluster(numCores)
registerDoParallel(cl)
# dummy datasets
x <- as.data.frame(matrix(runif(100000), 20000))
y <- gl(2, 10000)
parRf <- foreach(ntree = rep(treeSubs,numCores), .combine = randomForest::combine,
.packages = 'randomForest', .multicombine = TRUE) %dopar%
randomForest(x=x, y=y,
importance=TRUE,mtry=2,ntree = ntree,
replace = TRUE
)
z <- matrix(runif(1000), 200)
pred <- predict(parRf, z, type = "prob")
请注意,导致失败的是预测步骤,但是当我不并行调用 randomForest 时,预测步骤工作正常。或者,如果我使数据集更小,它也可以工作。在 RStudio 中,我得到了灰色的“炸弹”,而在 RGui 中,它就消失了。
以下是来自 Windows 事件日志的崩溃报告的一些详细信息:
Faulting application name: rsession.exe, version: 1.1.463.0, time stamp: 0x5bd11fb5
Faulting module name: randomForest.dll, version: 0.0.0.0, time stamp: 0x609f54bd
Exception code: 0xc0000005
Fault offset: 0x0000000000001b42
Faulting process id: 0x1e48
Faulting application start time: 0x01d752f21b6d7a79
Faulting application path: C:\Program Files\RStudio\bin\x64\rsession.exe
我想知道这是否与这个问题有关: R Crashes when training using caret and method = gamLoess 但我没有看到任何解决方案...
这是会议信息:
> sessionInfo()
R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server >= 2012 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] parallel stats graphics grDevices utils datasets methods base
other attached packages:
[1] doParallel_1.0.16 iterators_1.0.13 randomForest_4.6-14 foreach_1.5.1
loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5 codetools_0.2-18
>
提前感谢您的任何提示。
【问题讨论】:
标签: r foreach crash doparallel