2017-08-24 18 views
1

当我使用以下代码将库data.table加载到cpu集群时,R会引发错误。但data.table包安装在R上,并且在并行代码之外使用时工作正常。无法将库data.table加载到R并行

no_cores <- detectCores() - 1 
cl <- makeCluster(no_cores,outfile="out.txt") 
clusterEvalQ(cl, library(data.table)) 

错误: -

clusterEvalQ(cl, library(data.table)) Error in checkForRemoteErrors(lapply(cl, recvResult)) : 3 nodes produced errors; first error: there is no package called 'data.table'

+0

您是否安装了软件包?简单地说'library(data.table)'工作吗? –

+0

是的。我可以在并行代码外面使用此包,但出现问题 – navo

+0

无法重现错误。尝试更新R和包,重新启动会话等。 –

回答

0

建立在什么HenrikB上面说的意见,我被加入我的.libPaths(摆脱这个问题)调用clusterEvalQ():

.libPaths("C:/programs/rlib") 
library(parallel) 
no_cores<-detectCores()-1 

cl<-makeCluster(no_cores) 
#this is needed to see the package 
clusterEvalQ(cl, .libPaths("C:/programs/rlib")) 

# I'm using a function that uses the stringdist library 
clusterEvalQ(cl, library(stringdist)) 

#You need to load your data into the cluster also 
clusterExport(cl, "unmatched") 
clusterExport(cl, "matched") 

#now we're going to run it, amatch is a function in the stringdist lib 

parLapply(cl, unmatched,function(x) amatch(x,matched, maxDist = Inf))