无法将库数据加载到R并行表 [英] Cannot load library data.table to R parallel
问题描述
R引发错误.但是data.table程序包已安装在R上,并且在外部并行代码中使用时可以正常工作.
R throws an error when I use the below code to load library data.table to the cpu cluster. But data.table package is installed on R and it's working fine when used outside parallel code.
no_cores <- detectCores() - 1
cl <- makeCluster(no_cores,outfile="out.txt")
clusterEvalQ(cl, library(data.table))
错误:-
clusterEvalQ(cl,库(data.table)) checkForRemoteErrors(lapply(cl,recvResult))中的错误: 3个节点产生错误;第一个错误:没有名为"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'
推荐答案
在以上HenrikB在评论中所说的基础上,我通过将我的.libPaths()调用添加到clusterEvalQ()来摆脱了这个问题:
Building on what HenrikB said above in the comments, I got rid of this problem by adding my .libPaths() call to 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))
这篇关于无法将库数据加载到R并行表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!