如何从Python连接到H2O深水Docker镜像?

2024-06-09 17:20:25 发布

您现在位置:Python中文网/ 问答频道 /正文

还有一个问题,初学者:

我下载了深水小册子(http://docs.h2o.ai/h2o/latest-stable/h2o-docs/booklets/DeepWaterBooklet.pdf)中解释的H2O深水码头集装箱:

docker run -it --rm -p 54321:54321 -p 8080:8080 -v $PWD:/host opsh2oai/h2o-deepwater-cpu

java -jar /opt/h2o.jar

我成功地启动了H2O,并且可以通过本地浏览器中的Flow UI访问它本地主机:54321。在

我想做上面小册子中的mnistpython示例。我在python2.7中使用Anaconda和Spyder IDE。在

我认为我必须使用connect()方法,而不是使用init()。不管哪种方式都不起作用,我会得到超时、连接错误或HTTP异常,这取决于我尝试的。。。我尝试了几个IP(包括本地主机),例如:

^{pr2}$

我的启动日志显示以下内容。在

root@d54b0501b7c1:/# java -jar /opt/h2o.jar
08-11 08:46:32.904 172.17.0.2:54321      9      main      INFO: Found XGBoost backend with library: xgboost4j
08-11 08:46:32.926 172.17.0.2:54321      9      main      INFO: ----- H2O started  -----
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git branch: (HEAD detached at 0c917c766)
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git hash: 0c917c766f28860a19ff3f110e1f405eb9f41623
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build git describe: jenkins-master-3971
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build project version: 3.13.0.356 (latest version: 3.14.0.1)
08-11 08:46:32.928 172.17.0.2:54321      9      main      INFO: Build age: 12 days
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Built by: 'jenkins'
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Built on: '2017-07-29 13:31:58'
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git branch: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git hash: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build git describe: (unknown)
08-11 08:46:32.929 172.17.0.2:54321      9      main      INFO: Watchdog Build project version: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: Watchdog Built by: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: Watchdog Built on: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git branch: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git hash: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build git describe: (unknown)
08-11 08:46:32.930 172.17.0.2:54321      9      main      INFO: XGBoost Build project version: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: XGBoost Built by: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: XGBoost Built on: (unknown)
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Processed H2O arguments: []
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Java availableProcessors: 2
08-11 08:46:32.931 172.17.0.2:54321      9      main      INFO: Java heap totalMemory: 31.0 MB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Java heap maxMemory: 444.5 MB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Java version: Java 1.8.0_131 (from Oracle Corporation)
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: JVM launch parameters: []
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: OS version: Linux 4.9.36-moby (amd64)
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: Machine physical memory: 1.95 GB
08-11 08:46:32.932 172.17.0.2:54321      9      main      INFO: X-h2o-cluster-id: 1502441188713
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: User name: 'root'
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: IPv6 stack selected: false
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: Possible IP Address: eth0 (eth0), 172.17.0.2
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: Possible IP Address: lo (lo), 127.0.0.1
08-11 08:46:32.933 172.17.0.2:54321      9      main      INFO: H2O node running in unencrypted mode.
08-11 08:46:32.943 172.17.0.2:54321      9      main      INFO: Internal communication uses port: 54322
08-11 08:46:32.943 172.17.0.2:54321      9      main      INFO: Listening for HTTP and REST traffic on http://172.17.0.2:54321/
08-11 08:46:32.945 172.17.0.2:54321      9      main      INFO: H2O cloud name: 'root' on /172.17.0.2:54321, discovery address /225.53.128.226:57653
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO: If you have trouble connecting, try SSH tunneling from your local machine (e.g., via port 55555):
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO:   1. Open a terminal and run 'ssh -L 55555:localhost:54321 root@172.17.0.2'
08-11 08:46:32.946 172.17.0.2:54321      9      main      INFO:   2. Point your browser to http://localhost:55555
08-11 08:46:32.955 172.17.0.2:54321      9      main      INFO: Log dir: '/tmp/h2o-root/h2ologs'
08-11 08:46:32.957 172.17.0.2:54321      9      main      INFO: Cur dir: '/'
08-11 08:46:33.072 172.17.0.2:54321      9      main      INFO: HDFS subsystem successfully initialized
08-11 08:46:33.085 172.17.0.2:54321      9      main      INFO: S3 subsystem successfully initialized
08-11 08:46:33.088 172.17.0.2:54321      9      main      INFO: Flow dir: '/root/h2oflows'
08-11 08:46:33.142 172.17.0.2:54321      9      main      INFO: Cloud of size 1 formed [/172.17.0.2:54321]
08-11 08:46:33.166 172.17.0.2:54321      9      main      INFO: Registered parsers: [GUESS, ARFF, XLS, SVMLight, AVRO, PARQUET, CSV]
08-11 08:46:33.167 172.17.0.2:54321      9      main      INFO: Watchdog extension initialized
08-11 08:46:33.168 172.17.0.2:54321      9      main      INFO: XGBoost extension initialized
08-11 08:46:33.171 172.17.0.2:54321      9      main      INFO: Registered 2 core extensions in: 341ms
08-11 08:46:33.172 172.17.0.2:54321      9      main      INFO: Registered H2O core extensions: [Watchdog, XGBoost]
08-11 08:46:33.184 172.17.0.2:54321      9      main      INFO: Found XGBoost backend with library: xgboost4j
08-11 08:46:33.702 172.17.0.2:54321      9      main      INFO: Registered: 160 REST APIs in: 529ms
08-11 08:46:33.711 172.17.0.2:54321      9      main      INFO: Registered REST API extensions: [XGBoost, Algos, AutoML, Core V3, Core V4]
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: Registered: 230 schemas in 354ms
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: H2O started in 5343ms
08-11 08:46:34.073 172.17.0.2:54321      9      main      INFO: 
08-11 08:46:34.075 172.17.0.2:54321      9      main      INFO: Open H2O Flow in your web browser: http://172.17.0.2:54321

在我的Mac/上的Docker容器中,连接到这个H2O Deep Water Docker容器的正确Python代码或缺少的配置是什么?在

似乎是安全/Docker配置问题???在

h2o.connect(ip="127.0.0.1", port=54321)
Connecting to H2O server at http://127.0.0.1:54321...Traceback (most recent call last):

  File "<ipython-input-12-e78edc3b0d61>", line 1, in <module>
    h2o.connect(ip="127.0.0.1", port=54321)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/h2o.py", line 74, in connect
    cluster_id=cluster_id, cookies=cookies, verbose=verbose)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 175, in open
    conn._cluster = conn._test_connection(retries, messages=_msgs)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 414, in _test_connection
    cld = self.request("GET /3/Cloud")

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 259, in request
    return self._process_response(resp, save_to)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 574, in _process_response
    data = response.json(object_pairs_hook=H2OResponse)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/requests/models.py", line 877, in json
    self.content.decode(encoding), **kwargs

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/__init__.py", line 352, in loads
    return cls(encoding=encoding, **kw).decode(s)

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "/Users/kai.waehner/anaconda/lib/python2.7/json/decoder.py", line 380, in raw_decode
    obj, end = self.scan_once(s, idx)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/connection.py", line 691, in __new__
    if schema == "CloudV3": return H2OCluster.from_kvs(keyvals)

  File "/Users/kai.waehner/anaconda/lib/python2.7/site-packages/h2o/backend/cluster.py", line 47, in from_kvs
    raise AttributeError("Attribute %s cannot be set on H2OCluster (= %r)" % (k, v))

AttributeError: Attribute internal_security_enabled cannot be set on H2OCluster (= False)

谢谢你的帮助。在


Tags: inbuildinfomainliblineanacondausers
1条回答
网友
1楼 · 发布于 2024-06-09 17:20:25

当您在docker映像中启动h2o并使用-p54321:54321时,h2o将在本地主机:54321开运行docker的机器。然后可以用h2o.init()以正常方式连接。当init启动时,它将寻找一个正在运行的水,然后你有并连接到它。在

相关问题 更多 >