【发布时间】:2014-04-16 00:26:54
【问题描述】:
假设我正在尝试运行以下代码
library(gregmisc)
library(parallel)
myfunction <- function(x){
combinations(10, x, 1:10)
}
cl <- makeCluster(getOption("cl.cores", 2))
parLapply(cl, 3, myfunction)
我收到了错误
#Error in checkForRemoteErrors(val) :
#one node produced an error: could not find function "combinations"
所以,如果我在函数中库“gregmisc”包,它将起作用
myfunction <- function(x){
library(gregmisc)
combinations(10, x, 1:10)
}
cl <- makeCluster(getOption("cl.cores", 2))
parLapply(cl, 3, myfunction)
问题是,我怎样才能避免函数内的库包?
我看到在here 和here 中已经针对“雪”和“降雪”提出了类似的问题
但我无法让它为“并行”包工作
我试过了(没有成功)
library(snow)
library(snowfall)
sfExport(list=list("combinations"))
sfLibrary(gregmisc)
clusterEvalQ(cl, library(gregmisc))
【问题讨论】:
标签: r parallel-processing