gpt4 book ai didi

python - IPython 并行 Controller 可以同时具有本地和远程 ipengines 吗?

转载 作者:太空宇宙 更新时间:2023-11-03 11:03:22 25 4
gpt4 key购买 nike

IPython parallel docs提及:

c = Client(profile='myprofile')

c = Client('/path/to/my/ipcontroller-client.json')

用于本地 ipengines (IIUC) 和

c = Client('/path/to/my/ipcontroller-client.json', sshserver='me@myhub.example.com')

如果我的 ipengines 在另一台服务器上。

但是我需要做什么才能让 IPython 并行 Controller 管理来自本地节点的 8 个 ipengines 和来自远程节点的 8 个 ipengines,通过 SSH 连接?

或者如果不采用全面的 HDFS、Hadoop 等,这是不可能的吗?

我的目标是拥有一个客户端(或 Controller ?)接口(interface),我可以在其中以负载均衡的方式发送一堆计算,而我不在乎什么时候在哪里运行。

最佳答案

Client 的 sshserver arg 仅适用于无法从客户端直接访问 Controller 的情况(例如,笔记本电脑上的客户端,远程网络上防火墙后面的 Controller )。客户永远不需要知道或关心引擎在哪里。此外,仅当机器彼此无法访问时才需要 ssh 隧道。为简单起见,我假设您实际上不需要 ssh 隧道。

最简单的情况:

  • host1 是您要运行 Controller、Client 和 5 个引擎的地方
  • host2 是同一局域网中的另一台计算机,你想在其中启动 8 个引擎

无配置

  1. 启动 Controller ,监听所有接口(interface)(以便 LAN 上其他地方的引擎可以连接)

    [host1] ipcontroller --ip=*
  2. (如果共享文件系统则跳过)发送连接文件到host2

    [host1] rsync -av $HOME/.ipython/profile_default/security/ host2:.ipython/profile_default/security/
  3. 在host1上启动引擎

    [host1] ipengine
    # or start multiple engines at once:
    [host1] ipcluster engines -n 5
  4. 在 host2 上启动引擎

    [host2] ipengine
    # or start multiple engines at once:
    [host2] ipcluster engines -n 8
  5. 在主机 1 上打开一个客户端:

    [host1] ipython
    In[1]: from IPython import parallel
    In[2]: rc = parallel.Client()

您现在应该可以访问两台机器上的引擎。

配置

您也可以使用配置来表达所有这些。初始化配置文件:

[host1] ipython profile create --parallel

告诉 ipcontroller 监听 ipcontroller_config.py 中的所有接口(interface):

c.HubFactory.ip = '*'

ipcluster_config.py 中告诉 ipcluster 使用 ssh 在 host1 和 host2 上启动引擎:

c.IPClusterEngines.engine_launcher_class = 'SSH'
c.SSHEngineSetLauncher.engines = {
'host1': 5,
'host2': 8,
}

使用 ipcluster 启动一切:

[host1] ipcluster start

SSH 启动器将负责将连接文件复制到远程引擎。

如果你确实需要ssh隧道,你可以指定

c.IPControllerApp.ssh_server = u'host1'

ipcontroller_config.py 中。 IPython 应该能够判断引擎或客户端是否在 host1 上运行,并在不需要时跳过隧道。如果无法弄清楚,您可以手动指定应该在哪里使用 ssh 服务器并将其保留在配置之外,或者将其放入配置并手动指定不应该使用 ssh 服务器,以您更方便的方式为准.

关于python - IPython 并行 Controller 可以同时具有本地和远程 ipengines 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26823997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com