读取h2o R中的大(1.5 GB)文件

时间:2017-06-18 20:16:57

标签: r h2o

我正在使用h2o包在R中进行建模。为此,我想使用h2o.importfile()读取大小约为1.5 GB的数据集。我使用行

启动h2o服务器
library(h2oEnsemble)
h2o.init(max_mem_size = '1499m',nthreads=-1)

这会产生一个日志

H2O is not running yet, starting it now...
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode)

Starting H2O JVM and connecting: . Connection successful!

R is connected to the H2O cluster: 
H2O cluster uptime:         3 seconds 665 milliseconds 
H2O cluster version:        3.10.4.8 
H2O cluster version age:    28 days, 14 hours and 36 minutes  
H2O cluster name:           H2O_started_from_R_Lucifer_jvn970 
H2O cluster total nodes:    1 
H2O cluster total memory:   1.41 GB 
H2O cluster total cores:    4 
H2O cluster allowed cores:  4 
H2O cluster healthy:        TRUE 
H2O Connection ip:          localhost 
H2O Connection port:        54321 
H2O Connection proxy:       NA 
H2O Internal Security:      FALSE 
R Version:                  R version 3.3.2 (2016-10-31)` 

以下行给出了错误 train=h2o.importFile(path=normalizePath("C:\\Users\\All data\\traindt.rds"))

DistributedException from localhost/127.0.0.1:54321, caused by java.lang.AssertionError

DistributedException from localhost/127.0.0.1:54321, caused by java.lang.AssertionError
at water.MRTask.getResult(MRTask.java:478)
at water.MRTask.getResult(MRTask.java:486)
at water.MRTask.doAll(MRTask.java:402)
at water.parser.ParseDataset.parseAllKeys(ParseDataset.java:246)
at water.parser.ParseDataset.access$000(ParseDataset.java:27)
at water.parser.ParseDataset$ParserFJTask.compute2(ParseDataset.java:195)
at water.H2O$H2OCountedCompleter.compute(H2O.java:1315)
at jsr166y.CountedCompleter.exec(CountedCompleter.java:468)
at jsr166y.ForkJoinTask.doExec(ForkJoinTask.java:263)
at jsr166y.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:974)
at jsr166y.ForkJoinPool.runWorker(ForkJoinPool.java:1477)
at jsr166y.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:104)
Caused by: java.lang.AssertionError
at water.parser.Categorical.addKey(Categorical.java:41)
at water.parser.FVecParseWriter.addStrCol(FVecParseWriter.java:127)
at water.parser.CsvParser.parseChunk(CsvParser.java:133)
at water.parser.Parser.readOneFile(Parser.java:187)
at water.parser.Parser.streamParseZip(Parser.java:217)
at water.parser.ParseDataset$MultiFileParseTask.streamParse(ParseDataset.java:907)
at water.parser.ParseDataset$MultiFileParseTask.map(ParseDataset.java:856)
at water.MRTask.compute2(MRTask.java:601)
at water.H2O$H2OCountedCompleter.compute1(H2O.java:1318)
at water.parser.ParseDataset$MultiFileParseTask$Icer.compute1(ParseDataset$MultiFileParseTask$Icer.java)
at water.H2O$H2OCountedCompleter.compute(H2O.java:1314)
... 5 more

Error: DistributedException from localhost/127.0.0.1:54321, caused by java.lang.AssertionError

有关如何解决此问题的任何帮助? 注意:分配大于1499mb的内存也会给我一个错误(无法分配内存)。我使用的是16GB ram环境

编辑:我下载了64位版本的Java并将我的文件更改为csv文件。然后我能够将max_mem_size分配给5G,问题就解决了。

对于遇到问题的其他人: 1.下载最新版本的64位jdk 2.执行以下第line行

h2o.init(max_mem_size = '5g',nthreads=-1)

2 个答案:

答案 0 :(得分:2)

您运行的是32位java,这限制了您可以启动H2O的内存。一个线索是它不会以更高的max_mem_size开始。另一个线索是它说“Client VM”。

您需要64位Java。 64位版本将说“Server VM”。您可以从这里下载Java 8 SE JDK:

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

根据您所描述的内容,我建议设置max_mem_size ='6g'或更多,一旦安装了正确版本的Java,这将在您的系统上正常工作。

答案 1 :(得分:1)

train=h2o.importFile(path=normalizePath("C:\\Users\\All data\\traindt.rds")

您是否尝试加载.rds文件?这是一种R二进制格式,h2o.importFile()无法读取,因此不起作用。如果您想直接将其读入H2O,则需要以跨平台存储格式(例如CSV,SMVLight等)存储您的培训数据。如果您没有其他格式的副本,则只需从R:

中保存一个
# loads a `train` data.frame for example
load("C:\\Users\\All data\\traindt.rds")

# save as CSV
write.csv(train, "C:\\Users\\All data\\traindt.csv")

# import from CSV into H2O cluster directly
train = h2o.importFile(path = normalizePath("C:\\Users\\All data\\traindt.csv"))

另一种选择是将其从.rds文件加载到R并使用as.h2o()函数:

# loads a `train` data.frame for example
load("C:\\Users\\All data\\traindt.rds")

# send to H2O cluster
hf <- as.h2o(train)