使用ipcluster

时间:2017-11-02 16:10:35

标签: kernel ipython ipython-parallel

我有一个自定义的Jupyter内核。它使用kernel.json kernelspec。

指定

kernel.json的摘录显示了如何启动自定义内核:

source /opt/conda/bin/activate gdb_ipykernel &&  exec /opt/conda/envs/gdb_ipykernel/bin/python -m gdb_test.do_tests gdb_test._ipykernel -f {connection_file}

我想将此内核与IPython并行使用。例如,使用其中几个自定义内核运行ipcluster。

我创建了一个新的IPython配置文件

(ipython版本5.1.0)

ipython profile create --parallel --profile=gdb_gcc_par

这将创建一个包含各种配置(.py)文件的配置文件文件夹。

db              ipcluster_config.py     ipengine_config.py     ipython_config.py         log  security
history.sqlite  ipcontroller_config.py  ipython_config_old.py  ipython_kernel_config.py  pid  startup

我可以使用个人资料运行ipython

ipython --profile gdb_gcc_par --debug

输出:

(root) dinne@654f3bb1ef03:~/.ipython/profile_gdb_gcc_par$ ipython --profile gdb_gcc_par --debug
[TerminalIPythonApp] IPYTHONDIR set to: /home/dinne/.ipython
[TerminalIPythonApp] Using existing profile dir: '/home/dinne/.ipython/profile_gdb_gcc_par'
[TerminalIPythonApp] Searching path ['/home/dinne/.ipython/profile_gdb_gcc_par', '/home/dinne/.ipython/profile_gdb_gcc_par', '/usr/local/etc/ipy
thon', '/etc/ipython'] for config files
[TerminalIPythonApp] Attempting to load config file: ipython_config.py
[TerminalIPythonApp] Looking for ipython_config in /etc/ipython
[TerminalIPythonApp] Looking for ipython_config in /usr/local/etc/ipython
[TerminalIPythonApp] Looking for ipython_config in /home/dinne/.ipython/profile_gdb_gcc_par
[TerminalIPythonApp] Loaded config file: /home/dinne/.ipython/profile_gdb_gcc_par/ipython_config.py
[TerminalIPythonApp] Looking for ipython_config in /home/dinne/.ipython/profile_gdb_gcc_par
[TerminalIPythonApp] Loaded config file: /home/dinne/.ipython/profile_gdb_gcc_par/ipython_config.py
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul  2 2016, 17:53:06)
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

IPython profile: gdb_gcc_par

[TerminalIPythonApp] Loading IPython extensions...
[TerminalIPythonApp] Loading IPython extension: storemagic
[TerminalIPythonApp] Starting IPython's mainloop...

In [1]:

如果我在ipython_config.py中引入错误,我会看到一条错误消息,因此我认为此配置文件已被考虑在内。

如果我在ipython_kernel_config.py中引入错误,我没有看到任何更改,所以我得出结论,此配置文件被考虑在内?

如何指定要使用的内核?

我找到了这个网站:

http://andrew.gibiansky.com/blog/ipython/ipython-kernels/

包含此代码段:

c = get_config()
c.KernelManager.kernel_cmd = ["/path/to/executable/kernel_exe",
                              "{connection_file}"]  

我将代码段添加到ipython_config.py。但是这没有效果。

此外,我发现不推荐使用kernel_cmd

我尝试过的一些事情:

尝试1(无效)

ipcluster start --n=4 --KernelManager.kernel_cmd="['python', 'simple_kernel.py', '{con
nection_file}']"

尝试2(无效果):

添加到〜/ .ipython / profile_gdb_gcc_par / ipython_config.py

c.KernelManager.kernel_cmd=['python', 'simple_kernel.py', '{connection_file}']

运行

ipython --profile gdb_gcc_par

没效果。

0 个答案:

没有答案