2017-08-24 17 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))