Can't import binay h2o model with h2o.loadModel() function: 412 Precondition Failed

我是研究僧i 提交于 2021-02-15 04:59:08

问题


I've been working with h2o and h2o Flow for the past days and have loved it. Two days ago I exported some models (in binary format) from h2o Flow and imported them with R so I could do further studies. It worked perfectly until today. For some reason, I'm getting the following error when I try the h2o.loadModel function (which worked just fine before with all my exported binary models). Just to clarify, I already ran successfully the h2o.init() command to open the H2O cluster.

ERROR: Unexpected HTTP Status code: 412 Precondition Failed (url = http://localhost:54321/99/Models.bin/)

water.exceptions.H2OIllegalArgumentException
 [1] "water.exceptions.H2OIllegalArgumentException: Illegal argument: dir of function: importModel: H2O/H2O-XX/gbm_grid1_m02"
 [2] "    water.api.ModelsHandler.importModel(ModelsHandler.java:220)"                                                       
 [3] "    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)"                                                       
 [4] "    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)"                                     
 [5] "    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)"                             
 [6] "    java.lang.reflect.Method.invoke(Method.java:498)"                                                                  
 [7] "    water.api.Handler.handle(Handler.java:63)"                                                                         
 [8] "    water.api.RequestServer.serve(RequestServer.java:446)"                                                             
 [9] "    water.api.RequestServer.doGeneric(RequestServer.java:296)"                                                         
[10] "    water.api.RequestServer.doPost(RequestServer.java:222)"                                                            
[11] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:755)"                                                      
[12] "    javax.servlet.http.HttpServlet.service(HttpServlet.java:848)"                                                      
[13] "    org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:684)"                                            
[14] "    org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:503)"                                        
[15] "    org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1086)"                                
[16] "    org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:429)"                                         
[17] "    org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1020)"                                 
[18] "    org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:135)"                                     
[19] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"                             
[20] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"                                   
[21] "    water.JettyHTTPD$LoginHandler.handle(JettyHTTPD.java:189)"                                                         
[22] "    org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:154)"                             
[23] "    org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:116)"                                   
[24] "    org.eclipse.jetty.server.Server.handle(Server.java:370)"                                                           
[25] "    org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:494)"                    
[26] "    org.eclipse.jetty.server.BlockingHttpConnection.handleRequest(BlockingHttpConnection.java:53)"                     
[27] "    org.eclipse.jetty.server.AbstractHttpConnection.content(AbstractHttpConnection.java:982)"                          
[28] "    org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:1043)"          
[29] "    org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:865)"                                                  
[30] "    org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:240)"                                             
[31] "    org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:72)"                            
[32] "    org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:264)"                      
[33] "    org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:608)"                                  
[34] "    org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:543)"                                   
[35] "    java.lang.Thread.run(Thread.java:748)"                                                                             

Error in .h2o.doSafeREST(h2oRestApiVersion = h2oRestApiVersion, urlSuffix = page,  : 


ERROR MESSAGE:

Illegal argument: dir of function: importModel: H2O/H2O-XX/gbm_grid1_m02

Im using the latest h2o version, 3.15.0.4029, on RStudio, macOS Sierra (10.12.6 (16G29))

UPDATE: as requested by Erin, posting how I tried to import the model:

library(h2o)
#h2o.init(nthreads = -1, max_mem_size = "7G") # Already initiated 
#h2o.removeAll()   
h2oXX <- h2o.loadModel("H2O-XX/GBM_grid_0_AutoML_20171102_095446_model_41")

Downgraded to the latest stable version (h2o-3.14.0.7) and receiving the same error: Illegal argument: dir of function: importModel: H2O-XX/GBM_grid_0_AutoML_20171102_095446_model_41

Attached model (you can try to import it): bit.ly/h2odemo


回答1:


If you see an error that looks like this (key identifier being this statement Illegal argument: dir of function: importModel:)

ERROR: Unexpected HTTP Status code: 412 Precondition Failed (url = http://localhost:54321/99/Models.bin/)

water.exceptions.H2OIllegalArgumentException
[1] "water.exceptions.H2OIllegalArgumentException: Illegal argument: dir of function: importModel: H2O/H2O-XX/gbm_grid1_m02"

Then that probably means that you used a different version of H2O to train and save the model than you are using to load the H2O model. This is a problem because binary models (models saved using the h2o.saveModel() function) are not compatible between different versions of H2O.

The simple solution is to use the same version of H2O to save and re-load the model.

An alternative solution is to use the POJO or MOJO type H2O models. This format for models exports the model as plain Java code and is not tied to a particular version of H2O. It also does not require the H2O cluster to be running when you generate predictions on test data. This is typically what you'd want to use if you were to take your H2O models to production.



来源:https://stackoverflow.com/questions/47062207/cant-import-binay-h2o-model-with-h2o-loadmodel-function-412-precondition-fai

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!