【发布时间】:2017-11-28 20:16:01
【问题描述】:
我想从我的 Jupyter 笔记本动态启动集群以实现特定功能。虽然我可以启动集群并让引擎运行,但我遇到了两个问题:
(1) 我无法在后台运行 ipcluster 命令。当我通过笔记本运行命令时,单元一直运行到集群运行时,即我无法在同一个笔记本中运行更多单元。一旦引擎在不同的笔记本中启动,我就可以使用它们。如何在后台运行 ipcluster?
(2) 我的代码总是启动 8 个引擎,不管 ipcluster_config.py 中的设置如何。
代码:
server_num = 3
ip_new = '10.0.1.' + str(10+server_num)
cluster_profile = "ssh" + str(server_num)
import commands
import time
commands.getstatusoutput("ipython profile create --parallel --profile=" + cluster_profile)
text = """
c.SSHEngineSetLauncher.engines = {'""" +ip_new + """' : 12}
c.LocalControllerLauncher.controller_args = ["--ip=10.0.1.163"]
c.SSHEngineSetLauncher.engine_cmd = ['/home/ubuntu/anaconda2/pkgs/ipyparallel-6.0.2-py27_0/bin/ipengine']
"""
with open("/home/ubuntu/.ipython/profile_" + cluster_profile + "/ipcluster_config.py", "a") as myfile:
myfile.write(text)
result = commands.getstatusoutput("(ipcluster start --profile='"+ cluster_profile+"' &)")
time.sleep(120)
print(result[1])
【问题讨论】:
-
我在运行命令
!ipcluster start后遇到了类似的问题,笔记本内核仍然很忙。但我注意到,只需刷新页面,我就可以运行以释放内核并运行其他单元。你找到解决办法了吗?