11

I can't get the h2o to work in my R. It shows the following error. Have no clue what it means. Previously it gave me an error because I didn't have Java 64 bit version. I downloaded the 64bit - restarted my pc - and started the process again and now it gives me this error.

Any suggestions?

library(h2o)

----------------------------------------------------------------------

Your next step is to start H2O:
    > h2o.init()

For H2O package documentation, ask for help:
    > ??h2o

After starting H2O, you can use the Web UI at http://localhost:54321
For more information visit http://docs.h2o.ai

----------------------------------------------------------------------


Attaching package: ‘h2o’

The following objects are masked from ‘package:stats’:

    cor, sd, var

The following objects are masked from ‘package:base’:

    %*%, %in%, &&, ||, apply, as.factor, as.numeric, colnames, colnames<-, ifelse,
    is.character, is.factor, is.numeric, log, log10, log1p, log2, round, signif, trunc

> h2o.init(nthreads = -1)

H2O is not running yet, starting it now...

Note:  In case of errors look at the following log files:
    C:\Users\ADM_MA~1\AppData\Local\Temp\RtmpygK1EJ/h2o_Adm_Mayur_started_from_r.out
    C:\Users\ADM_MA~1\AppData\Local\Temp\RtmpygK1EJ/h2o_Adm_Mayur_started_from_r.err

java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)

Starting H2O JVM and connecting: ............................................................ 
[1] "localhost"
[1] 54321
[1] TRUE
[1] -1
[1] "Failed to connect to localhost port 54321: Connection refused"
[1] 127
Error in h2o.init(nthreads = -1) : 
  H2O failed to start, stopping execution.
In addition: Warning message:
running command 'curl 'http://localhost:54321'' had status 127 

Screenshot for h2o error in R

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197
Mayur
  • 179
  • 1
  • 2
  • 12
  • 2
    Java may not be found. Can you try loading RJava? After that, if you can load RJava but still have the problem, the next step is to try running the H2O .jar file from the Windows (or linux, etc) command line. Can you do that? – Hack-R Sep 24 '17 at 16:55
  • So I am getting this error when I am trying to load the rJava - Note: I am using R version 3.4.1 Also, note: I'm looking for some rope here as I am not a regular programmer. So request you to please dumb your reply down for me. I need this h2o package for a deep learning course from Udemy. But I am not very exposed to the topic. > library(rJava) Error: package or namespace load failed for ‘rJava’: .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry Any suggestions? – Mayur Sep 24 '17 at 18:31
  • I also made sure that I am using 64 bit version for R and Java. So that's definitely not the error. – Mayur Sep 24 '17 at 18:39
  • The error is saying that you haven't properly set the JAVA_HOME environment variable. I don't know what OS you are using but if you just Google how to do that there are lots of walk throughs. You just have to define that variable with the path to the Java bin folder. – Hack-R Sep 24 '17 at 18:41
  • 1
    Basically, like this. But you need to verify the path `Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre7')` – Hack-R Sep 24 '17 at 18:43
  • Ok. That was helpful. I set the JAVA_HOME environment variable but my original problem still exits. Can you tell me how do I go about running the h2o.jar file from the command line? Some simpler steps like you mentioned for Java. Many thanks. – Mayur Sep 24 '17 at 19:21
  • OK sure. I still don't know your OS, but I will assume it's Windows. Click Start then Run then type cmd.exe then press enter. The use `cd` to navigate to the director with `h2o.jar`. Then type `java -jar h2o.jar` – Hack-R Sep 24 '17 at 19:36
  • You assumed right. It's windows. I'm almost there after following your instructions. But stuck at the last part. I navigated the director and finally got an error saying that Java 9 is not supported: "C:\Users\Adm_Mayur\Documents\R\win-library\3.4\h2o\java>java -jar h2o.jar Only Java 1.6-1.8 supported, version is 9" – Mayur Sep 24 '17 at 20:12
  • I am surprised about that but at least now we know the problem. Please make sure you are using a new version of H2O. What version is it? If H2O is up to date then you can download Java 1.8 just for this 1 purpose. If you don't mind I will make this into an answer so that I can hopefully get some points :) – Hack-R Sep 24 '17 at 20:13
  • If you want to use Java 1.8 just for this the way to do it on the command line is to specify the full path to java.exe instead of just typing `java`. So it would be like this `C:/Program Files/Java9/jre9/java.exe -jar h2o.jar`. – Hack-R Sep 24 '17 at 20:18
  • After setting Sys.setenv(JAVA_HOME='/Library/Java/JavaVirtualMachines/jdk1.8.0_151.jdk/Contents/Home') - it works! – Andrii Oct 02 '19 at 20:23

2 Answers2

10

Based on the error message and the troubleshooting we carried out in the comments, it seems that you are using a version of Java (Java 1.9) which is too new for your version of H2O.

Your 2 options seem to be:

  1. Verify that your version of H2O is up to date. If not, update it.
  2. Download a compatible version of Java, i.e. Java 1.8 (you can just use it for this 1 task rather than for everything, if you prefer)

Note that on the main documentation page of H2O v3 it says:

Java 7 or later. Note: Java 9 is not yet released and is not currently supported.

But at the same time they usually have several Beta and Alpha development branches going, so you might find one of those that works with Java 9.

Erin LeDell
  • 8,704
  • 1
  • 19
  • 35
Hack-R
  • 22,422
  • 14
  • 75
  • 131
  • 1
    Finally................... It worked. Thanks Hack and Erin... I uninstalled my java 9 and am now running java 8 to run the h2o library directly from r. – Mayur Sep 25 '17 at 03:38
  • 1
    @Mayur You are very welcome. If you don't mind terribly could you click the green check mark by my answer so that I can get credit? :) – Hack-R Sep 25 '17 at 22:08
  • 1
    downgrading to 8.0.161 worked for me too, just uninstall JDK9 and install JDK8, thanks – Selcuk Akbas Feb 26 '18 at 18:11
6

So if anyone else is facing the same issue.

My recommendation (after spending about over 10 hours trying to figure this out (worth mentioning)) is check your version of java.

If it's higher than 8 then either keep it remove it.

I removed it because I didn't want to deal with setting the JAVA Home function in R and to reduce work.

Make sure you install Java 7 or 8 but a 64 bit version. h2o doesn't work if you have 32 bit.

Then voila! Just go ahead and type install.package('h2o') in your rstudio.

I wanted to be extra careful in my final attempt of this so unloaded and uninstalled the library because I had installed it before and then installed it again and then loaded it using library(h2o) and then h20.init() worked just fine.

sm925
  • 2,648
  • 1
  • 16
  • 28
Mayur
  • 179
  • 1
  • 2
  • 12
  • 1
    Gotta get this information more available. Spent way too much time messing with R settings trying to figure out why I was only predicting one class in a neural net. h2o group needs to acknowledge which version of Java we need to be on, and either bundle it or link it with the h2o package. Thanks for the solution. – SeldomSeenSlim Mar 01 '18 at 16:56
  • @Erin LeDell - User feedback. Please pass it along to your documentation team. :) H2o is great, btw. – Mayur Apr 12 '18 at 21:58