2013-02-19 24 views
0

有沒有人有成功將大型陣列導出到R中的雪羣? bigmatrix和attach.resource示例中的註釋行表示可以這樣做,但我沒有取得成功。當將大型陣列導出爲雪羣時,R會崩潰

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", [email protected]) 
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

我終於發現了問題。看起來問題出現在打印結果時:

如果obj是big.matrix,則big.clusterEvalQ(cl,{obj})會給出錯誤。

因此,要解決該問題的方法是通過attach.resource功能後simplily加上一個常數:

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