多年来,我在R中多次执行函数脚本。在函数定义中,我使用以下方法在多核Windows工作站上设置了一个并行集群:
# cores0 <- 20 (cores set to 20 outside of function definition)
cl.spec <- rep("localhost", cores0)
cl <- makeCluster(cl.spec, type="SOCK", outfile="")
registerDoParallel(cl, cores=cores0)
从昨天起,我的函数执行不再工作,被挂了几个小时。(此外,使用资源监视器,我可以看到,尽管我的脚本指定了20个核心,但我的CPU中没有一个是活动的)。当我返回函数并逐行测试时,我发现下面的行没有执行(也就是说,当它通常在几秒钟内执行时,就会被挂起):
cl.spec <- rep("localhost", cores0)
cl <- makeCluster(cl.spec, type="SOCK", outfile="")
我试着查找这个问题,并找到了几个关于使用" PSOCK“类型的引用,但无法确定何时使用PSOCK与SOCK。尽管如此,我还是尝试使用"PSOCK“而不是”SOCK“来使用相同的脚本:
cl <- makeCluster(cl.spec, type="PSOCK", outfile="")
registerDoParallel(cl, cores=cores0)
随着PSOCK的修改,它不再被挂起,它似乎执行这个以及registerDoParallel()调用。
但是,当我执行包含上述两行的完整函数并调用该函数时,如下面所示,我得到了一个从未见过的错误:
Error in checkForRemoteErrors(lapply(cl, recvResult)) :
20 nodes produced errors; first error: object '.doSnowGlobals' not found
我也尝试不指定类型或外部文件,但这会产生与使用type="PSOCK“相同的错误。
cl <- makeCluster(cl.spec)
registerDoParallel(cl, cores=cores0)
我的问题是: 1.为什么makeCluster()线会被挂掉,而它以前从未被挂过?cl <- makeCluster(cl.spec,type="SOCK",outfile=“)
下面是包含makeCluster()和registerDoParallel()调用的函数定义和函数调用,如下所示:
# FUNCTION DEFINITION
FX_RFprocessingSNPruns <- function(path, CurrentRoundSNPlist, colSAMP, Nruns, ntreeIN, coresIN,CurrentRoundGTframeRDA){
...do a bunch of steps ...
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
# SET UP INTERNAL FUNCTION
#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
ImpOOBerr<-function(x,y,d) {
create function
}
#################################################################
# SET UP THE CLUSTER
#################################################################
#Setup clusters via parallel/DoParallel
cl.spec <- rep("localhost", cores0)
cl <- makeCluster(cl.spec, type="PSOCK", outfile="")
registerDoParallel(cl, cores=cores0)
#################################################################
# *** EMPLOY foreach TO CARRY OUT randomForest IN PARALLEL
#################################################################
system.time(RFoutput_runs <- foreach(i=1:Nruns0, .combine='cbind', .packages= 'randomForest', .inorder=FALSE, .multicombine=TRUE, .errorhandling="remove")
%dopar% {
...do a bunch of steps ...
ImpOOBerr(x,y,d)
})
#################################################################
# STOP THE CLUSTER
#################################################################
stopCluster(cl)
return(RFoutput_runs)
}
# CALL FUNCTION
path0="C:/USERS/KDA/WORKING/"
system.time(GTtest_5runs <- FX_RFprocessingSNPruns(
path=path0,
CurrentRoundSNPlist="SNPlist.rda",
colSAMP=20,
Nruns=5,
ntreeIN=150,
coresIN=5,
CurrentRoundGTframeRDA="GT.rda"))
#Error in checkForRemoteErrors(lapply(cl, recvResult)) :
# 20 nodes produced errors; first error: object '.doSnowGlobals' not found.
我发现这些帖子引用了错误,但是这些解决方案并不适用于我:error: object '.doSnowGlobals' not found? http://grokbase.com/t/r/r-sig-hpc/148880dpsm/error-object-dosnowglobals-not-found
我在Windows 8机器上工作,64位,有40个核心。
R.Version()
$platform
[1] "x86_64-w64-mingw32"
$arch
[1] "x86_64"
$os
[1] "mingw32"
$system
[1] "x86_64, mingw32"
$status
[1] ""
$major
[1] "3"
$minor
[1] "3.0"
$year
[1] "2016"
$month
[1] "05"
$day
[1] "03"
$`svn rev`
[1] "70573"
$language
[1] "R"
$version.string
[1] "R version 3.3.0 (2016-05-03)"
$nickname
[1] "Supposedly Educational"
R版本3.3.0 ( 2016 -05-03) -“假定教育”版权(C) 2016统计计算平台R基金会:x86_64-W64-mingw32 32/x64(64位)
发布于 2016-06-03 20:19:57
这是一个机构的防病毒软件,阻止进入核心。
https://stackoverflow.com/questions/37620234
复制相似问题