Error with H2O in R - can't connect to local host - r

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

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:
Verify that your version of H2O is up to date. If not, update it.
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.

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.

Related

Model training fails with h2o deepwater

While trying to train a lenet model for multiclass classification using h2o deepwater using mxnet backed I am getting the following errors:
Loading H2O mxnet bindings.
Found CUDA_HOME or CUDA_PATH environment variable, trying to connect to GPU devices.
Loading CUDA library.
Loading mxnet library.
Loading H2O mxnet bindings.
Done loading H2O mxnet bindings.
Constructing model.
Done constructing model.
Building network.
mxnet data input shape: (32,100)
[10:40:16] /home/jenkins/slave_dir_from_mr-0xb1/workspace/deepwater-master/thirdparty/mxnet/dmlc-core/include/dmlc/logging.h:235: [10:40:16] src/operator/./convolution-inl.h:349: Check failed: (dshape.ndim()) == (4) Input data should be 4D in batch-num_filter-y-x
[10:40:16] src/symbol.cxx:189: Check failed: (MXSymbolInferShape(GetHandle(), keys.size(), keys.data(), arg_ind_ptr.data(), arg_shape_data.data(), &in_shape_size, &in_shape_ndim, &in_shape_data, &out_shape_size, &out_shape_ndim, &out_shape_data, &aux_shape_size, &aux_shape_ndim, &aux_shape_data, &complete)) == (0)
The details of my setup :
* Ubuntu : 16.04
* Ram : 12gb
* Graphics card : Nvidia 920mx driver version : 384.90
* Cuda : 8.0.61
* cudnn : 6.0
* R version : 3.4.3
* H2o version : 3.15.0.393 & h2o-R package : 3.16.0.2
* mxnet : 0.11.0
* Train data size : 400mb (when converting to the h2o frame object it comes around 822mb)
Things I have done :
1.) Gave enough memory to java heap while running h2o cluster (java -Xmx9g -jar h2o.jar)
2.) Build the mxnet from source for gpu
3.) Monitored the gpu and system via nvidia-smi and system monitor. At no point do they eat up all the ram to show "out of memory" issue. I still will be having around 2-3gb free before the error shows up
4.) Have tried with tensorflow-gpu(build from source). Checking the pip list made sure that its installed but during model creation in R it gives the error :
Error: java.lang.RuntimeException: Unable to initialize the native Deep Learning backend: null
5.) The only method I got it the h2o deepwater to work with all the backend and w/wo GPU is through docker setup provided in the installation tutorials.
I wanted the same functionality on my laptop instead of using Docker. Also is there any way to run deepwater using just CPU? The link Is it possible to build Deep Water/TensorFlow model in H2O without CUDA doesn't provide any helpful answers. Any help or advice will be greatly appreciated!
As evident from the error logs and from documentation of mxnet.sym.Convolution your data needs to be in [batch, channels, height, width] format. However it looks like your data contains only two dimensions (based on this log: mxnet data input shape: (32,100)). Reformatting the data, even including two dimensions of size 1 such that your input shape is (1,1,32,100) should resolve this issue.

Trouble with data loading to H2O on R in Windows

I have problems with data loading to H2O in R on Windows. When I run basic commands such as h2o.clusterInfo or as.h2o(localH2O, dat, key = 'dat'), I got an error message - Error in .... : unused argument (...). Like on screen. I use RTVS na Microsoft R Open 3.2.5
The reason that code no longer works is that it's syntax from the H2O 2.0 API, which has been retired for about a year or longer. Since H2O 3.0, h2o.clusterInfo() no longer has arguments and as.h2o() no longer has the key argument. Check out the documentation for these functions inside your H2O R package, or here and here.

Error when calling h2o.init() in R to connecting to remote cluster

I'm trying to connect to the cluster hosted on EC2 machine from R and getting the same error when trying both on Windows and Mac:
> h2o.init(ip = "<Public IP>")
Connection successful!
ERROR: Unexpected HTTP Status code: 404 Not Found (url = http://<Public IP>:54321/3/Cloud?skip_ticks=true)
Error: lexical error: invalid char in json text.
<!DOCTYPE html> <html lang="en"
(right here) ------^
Cluster is reachable at http://<Public IP>:54321/
Starting a local cluster with h2o.init() also works fine in R, so the problem is only when trying to connect to remote one.
I've seen the following issue marked as resolved, but it doesn't help in my case. Have anybody experienced anything similar?
UPD: The answer was very simple. It turns out that the code example given in their guide for EC2 is outdated and uses the old version of H2O. Using the most recent version (3.9.1.5555 at the moment) on EC2 machines has resolved the issue.
To elaborate on the OP's update, when using a remote cluster:
Make sure you install the most recent version (check the S3 download page for the redirect to the release number). In the example below, this is 3.13.0.3908:
wget http://s3.amazonaws.com/h2o-release/h2o/master/3908/h2o-3.13.0.3908.zip
unzip h2o-3.13.0.3908.zip
mv h2o-3.13.0.3908 h2o
cd h2o
java -Xmx4g -jar h2o.jar
You then need to install the version of h2o-R that corresponds to this version. (The correct version is likely not the CRAN version.) Otherwise you will get an error like:
Error in h2o.init(ip = "XXX.XX.XX.XXX", startH2O = FALSE) :
Version mismatch! H2O is running version 3.13.0.3908 but h2o-R package is version 3.10.4.6.
Install the matching h2o-R version from - http://h2o-release.s3.amazonaws.com/h2o/master/3908/index.html
So you need to note the version number H2O is running (in the above example, 3908), make sure you have previously removed any existing h2o-R package (see here for more info), and then do:
install.packages("h2o", type="source", repos="http://h2o-release.s3.amazonaws.com/h2o/master/3908/R")
Now it should work:
library('h2o')
remoteH2O <- h2o.init(ip='XXX.XX.XX.XXX', startH2O=FALSE) # Connection successful!

R MongoDB command errors crash R session

This is not a question but a request to help diagnose and fix a problem.
Using the latest (1.0.2) version of rmongodb the following code crashes the session of R 2.15.2 on Mac OS X. The code works in R 2.15.1 on a different Mac OS X machine.
library(rmongodb)
mongo <- mongo.create('127.0.0.1', db='test')
print(mongo.is.connected(mongo))
mongo.find.one(mongo, 'unknown')
The output is:
> library(rmongodb)
rmongodb package (mongo-r-driver) loaded
Use 'help("mongo")' to get started.
> mongo <- mongo.create('127.0.0.1', db='test')
> print(mongo.is.connected(mongo))
[1] TRUE
> mongo.find.one(mongo, 'unknown')
R(60519) malloc: *** error for object 0x7fff5fbfce10: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
The same type of crash happens if you pass a non-existent command to MongoDB. Again, this used to work under R 2.15.1.
> library(rmongodb)
> mongo <- mongo.create('127.0.0.1', db='test')
> mongo.command(mongo, 'test', list(isMaster=1))
ismaster : 8 true
maxBsonObjectSize : 16 16777216
ok : 1 1.000000
> mongo.command(mongo, 'test', list(fake=1))
R(66743) malloc: *** error for object 0x7fff5fbfde20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
I have created an issue in the rmongodb project and would appreciate any help scoping & validating the problem to enable the package developer to hone in on what needs fixing or, perhaps, prove that it is not an rmongodb issue but some strange interaction in my environment.
I will accept an answer from someone who runs the code either on 2.15.1 and 2.15.2 on Mac OS X or on 2.15.2 on Mac OS X and at least one other environment.
According to the package author this issue is fixed on GitHub but CRAN hasn't been updated.

Parallel processing in R 2.11 Windows 64-bit using SNOW not quite working

I'm running R 2.11 64-bit on a WinXP64 machine with 8 processors. With R 2.10.1 the following code spawned 6 R processes for parallel processing:
require(foreach)
require(doSNOW)
cl = makeCluster(6, type='SOCK')
registerDoSNOW(cl)
bl2 = foreach(i=icount(length(unqmrno))) %dopar% {
(Some code here)
}
stopCluster(cl)
When I run the same code in R 2.11 Win64, the 6 R processes are not spawning, and the code hangs. I'm wondering if this is a problem with the port of SNOW to 2.11-64bit, or if any additional code is required on my part. Thanks
BTW, this works just fine on my multicore machine at home running Ubuntu Karmic 64-bit and R 2.11. Unfortunately I have to work on Win64 at work
The code seems to be working here.
R version 2.11.0 (2010-04-22)
x86_64-pc-mingw32
other attached packages:
[1] doSNOW_1.0.3 snow_0.3-3 foreach_1.3.0 codetools_0.2-2
[5] iterators_1.0.3
loaded via a namespace (and not attached):
[1] tools_2.11.0
Check your sessionInfo() to make sure your versions match mine. One thing I noted is that on my Windows 7 machine the first attempt to makeCluster made a request for a firewall exception. If you did not explicitly make allowances for the socket communication that could be why it is hanging. The defaults it opened (ugly as it is) was all TCP and UDP ports when operating under the private profile.
It is an old question, but I encountered the same problems with R-2.13.1 64 on Win 64 bits.
doSNOW was working fine with R 32-bits but not with R 64-bits, and was hanging at "cl = makeCluster(6, type='SOCK')" as well.
To resolve the problem I eventually added "C:\Program Files\R\R-2.13.1\bin\x64" to the %PATH% environment variable (win+pause/advanced system settings/advanced/environment variables/system variables). Make also sure to allow the R connections in Windows Firewall, and that C:\Program Files\R\R-2.13.1\bin contains copy of the 32-bits version of R.exe and Rscript.exe (not the x64 ones).
After doing this, when running makeCluster() 12 processes are started, 6 32 bits and 6 64 bits, but during the calculations only the 64 bits one are used.

Resources