将bigmatrix导出到雪群时,R崩溃

时间:2013-02-19 03:58:17

标签: r snow r-bigmemory

有没有人在这里成功将bigmatrix导出到R中的雪群? bigmatrix和attach.resource示例中的注释行说可以这样做,但我没有成功。

library(bigmemory)
library(snow)
z <- big.matrix(3, 3, type='integer', init=3)
cl = makeCluster(8, type = "SOCK")
clusterEvalQ(cl,{library(bigmemory)})
zdescription <- describe(z)
clusterExport(cl,"zdescription")
clusterEvalQ(cl,{y <- attach.resource(zdescription)}) #attach.big.matrix also crashes

即使我使用文件支持的大矩阵也会崩溃(这很奇怪,因为它甚至不使用共享内存)

[[1]]
Warning: This is not advised.  Here is the head of the matrix:

 *** caught segfault ***
address 0x10, cause 'memory not mapped'

Traceback:
 1: .Call("CGetNrow", x@address)
 2: nrow(x)
 3: nrow(x)
 4: .local(x, ...)
 5: head(x)
 6: head(x)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

1 个答案:

答案 0 :(得分:2)

我终于发现了这个问题。打印结果时看起来问题是:

如果obj是big.matrix,则big.clusterEvalQ(cl,{obj})会出错。

因此解决问题的方法是在attach.resource函数之后简单地添加一个常量:

clusterEvalQ(cl,{y <- attach.resource(zdescription);1})