基于这里的这篇文章,我尝试编写一个脚本,在这里看到:
library(parallel)
library(doParallel)
cl<-makeCluster(2,outfile='')
registerDoParallel(cl)
foreach(i=1:5, .packages='parallel') %dopar% {
system.time(mclapply(1:10, function(x){rnorm(1e5)},mc.cores=2))
}
stopCluster(cl)
它最初工作,但现在抛出错误代码:
Error in unserialize(node$con) : error reading from connection
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted
Error in unserialize(socklist[[n]]) : error reading from connection
Error in unserialize(node$con) : error reading from connection
Calls: <Anonymous> ... doTryCatch -> recvData -> recvData.SOCKnode -> unserialize
Execution halted
知道发生了什么吗?甚至可以将 mclapply 放在 foreach 循环中吗?
编辑:我还想说这是在单个 8 核机器上,而不是集群上。