others - 在 R 中,并行处理doParallel错误: serialize(data, node$con) : error writing to connection


 library(foreach)


 library(doParallel)


 cl <- makeCluster(7)


 registerDoParallel(cl) 



 elasticitylist = foreach(i=1:nhousehold) %dopar% {



 pricedraws = out$betadraw[i,12,] 


 elasticitydraws[,,i]= probarray[,,i] %*% diag(pricedraws)


 elasticitydraws[,,i] = elasticitydraws[,,i] * as.vector(medianpricemat)



 } 



我不断收到这个错误:


Error in serialize(data, node$con) : error writing to connection



谁能帮上忙?在文档中找不到答案!

当我运行时ps -ef| grep user在unix服务器上,我得到:


/apps/R.3.1.2/lib64/R/bin/exec/R --slave --no-restore -e parallel:::.slaveRSOCK() --args MASTER=localhost PORT=11025 OUT=/dev/null TIMEOUT=2592000 METHODS=TRUE XDR=TRUE



时间:

系统需要打开1个核心服务,否则你会得到一个错误:


library(doParallel)


#Find out how many cores are available (if you don't already know)


cores<-detectCores()


#Create cluster with desired number of cores, leave one open for the machine 


#core processes


cl <- makeCluster(cores[1]-1)


#Register cluster


registerDoParallel(cl)



...