错误:对象'.doSnowGlobals'找不到? [英] error: object '.doSnowGlobals' not found?

查看:1681
本文介绍了错误:对象'.doSnowGlobals'找不到?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在4个节点上并行化一个代码(type =SOCK)。这里是我的代码。

pre $ library $($ $ $ $ $ $ $ $库
库(并行)

工作地址 - 4个节点的IP地址
cl = makePSOCKcluster(worker,master =主地址)
registerDoParallel(cl )
$ b $< - read.csv(ProcessedData.csv,header = TRUE,as.is = TRUE)
z< - as.matrix(z)


system.time({
chunks< - getDoParWorkers())
b< - foreach(这些= isplitIndices(nrow(z),
chunks = chunks)
.combine = c)%dopar%{
a < - rep(0,length(these))
for(i in 1:length(these)){
a [ i]< - mean(z [these [i],])
}
a
}
})

我得到这个错误.4个节点产生错误;第一个错误:找不到.doSnowGlobals对象。这个代码运行良好,如果我使用doMC,即使用相同的机器的核心。但是当我尝试使用其他计算机进行并行计算时,出现上述错误。当我将其更改为registerDoSNOW时,错误仍然存​​在。

Snow和DoSNOW在集群中工作吗?我可以使用雪在本地主机上创建节点,但不能在集群上创建节点。任何人在那里使用雪?

解决方案

如果任何工作人员无法加载doParallel包,您可以得到此错误。您可以通过将doParallel安装到某个目录并通过.libPaths指向主服务器来实现:

 > .libPaths('〜/ R / lib.test')
>库(doParallel)
> cl< - makePSOCKcluster(3,outfile ='')
启动worker pid = 26240 on localhost:11566 at 13:47:59.470
启动worker pid = 26248 on localhost:11566 at 13:47: 59.667
启动worker pid = 26256 on localhost:11566 at 13:47:59.864
> registerDoParallel(cl)
> foreach(i = 1:10)%dopar%i
警告:命名空间'doParallel'不可用,并在处理对象'
时被.GlobalEnv替换
警告:命名空间'doParallel '不可用,在处理对象'
时被.GlobalEnv替换
警告:'doParallel'命名空间不可用,在处理对象''$时已经被.GlobalEnv替换为
。 b $ b checkForRemoteErrors错误(lapply(cl,recvResult)):
3个节点产生错误;第一个错误:对象'.doSnowGlobals'找不到

当doParallel函数被反序列化一位工人。错误发生在函数执行时,并试图访问在doParallel命名空间中定义的.doSnowGlobal,而不是在.GlobalEnv中。

您也可以验证doParallel是否可用通过执行:

 > clusterEvalQ(cl,library(doParallel))
checkForRemoteErrors错误(lapply(cl,recvResult)):
3个节点产生错误;第一个错误:没有包名为doParallel


I'm trying to parallelize a code on 4 nodes(type = "SOCK"). Here is my code.

library(itertools)
library(foreach)
library(doParallel)
library(parallel)

workers <- ip address of 4 nodes
cl = makePSOCKcluster(workers, master="ip address of master")
registerDoParallel(cl)

z <- read.csv("ProcessedData.csv", header=TRUE, as.is=TRUE)
z <- as.matrix(z)


system.time({
  chunks <- getDoParWorkers()
  b <- foreach (these = isplitIndices(nrow(z),
                                      chunks=chunks),
                .combine = c) %dopar% {
                  a <- rep(0, length(these))
                  for (i in 1:length(these)) {
                    a[i] <- mean(z[these[i],])
                  }
                  a
                }
})

I get this error..4 nodes produced errors; first error: object '.doSnowGlobals' not found. This code runs fine if I'm using doMC i.e using the same machine's cores. But when I try to use other computers for parallel computing I get the above error. When I change it to registerDoSNOW the error persists.

Does snow and DoSNOW work in a cluster? I could create nodes on the localhost using snow but not on the cluster. Anyone out there using snow?

解决方案

You can get this error if any of the workers are unable to load the doParallel package. You can make that happen by installing doParallel into some directory and pointing the master to it via ".libPaths":

> .libPaths('~/R/lib.test')
> library(doParallel)
> cl <- makePSOCKcluster(3, outfile='')
starting worker pid=26240 on localhost:11566 at 13:47:59.470
starting worker pid=26248 on localhost:11566 at 13:47:59.667
starting worker pid=26256 on localhost:11566 at 13:47:59.864
> registerDoParallel(cl)
> foreach(i=1:10) %dopar% i
Warning: namespace ‘doParallel’ is not available and has been replaced
by .GlobalEnv when processing object ‘’
Warning: namespace ‘doParallel’ is not available and has been replaced
by .GlobalEnv when processing object ‘’
Warning: namespace ‘doParallel’ is not available and has been replaced
by .GlobalEnv when processing object ‘’
Error in checkForRemoteErrors(lapply(cl, recvResult)) : 
  3 nodes produced errors; first error: object '.doSnowGlobals' not found

The warning happens when a function from doParallel is deserialized on a worker. The error happens when the function is executed and tries to access .doSnowGlobal which is defined in the doParallel namespace, not in .GlobalEnv.

You can also verify that doParallel is available on the workers by executing:

> clusterEvalQ(cl, library(doParallel))
Error in checkForRemoteErrors(lapply(cl, recvResult)) : 
  3 nodes produced errors; first error: there is no package called ‘doParallel’

这篇关于错误:对象'.doSnowGlobals'找不到?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆