通过批处理队列运行ipython内核
remote_ikernel的Python项目详细描述
所有的朱庇特核,在所有的机器上,在一个地方。
在远程系统上通过批处理队列启动jupyter内核,以便 它们可以在本地jupyter notebook中使用。
jupyter兼容内核通过批处理队列中的交互式作业启动 系统(sge、slurm、pbs…)或通过ssh连接。一旦内核 首先,为通信端口创建ssh隧道,因此 笔记本可以与内核进行对话,就好像它是本地的一样。
包括用于管理内核的命令。也可以使用 remote_ikernel管理来自不同虚拟环境的内核,或者 不同的python实现。
使用pip install remote_ikernel安装。需要notebook(作为部分 jupyter的),4.0或更高版本和pexpect。无密码ssh 对于所有远程计算机,也建议使用(例如群集上的节点)。
警告
remote_ikernel在多台计算机上打开多个连接 到隧道通信端口。如果你担心安全或者 过度使用资源,请咨询系统管理员 在使用本软件之前。
注意
当在远程机器上运行内核时,笔记本本身将 保存到本地文件系统中,但内核将只具有访问权限 到运行内核的远程计算机的文件系统。如果你需要分享 目录,在计算机之间设置sshfs。
# Install the module ('python setup.py install' also works)
pip install remote_ikernel
# Set up the kernels you'd like to use
remote_ikernel manage
# Add a new kernel running through GrideEngine remote_ikernel manage --add \ --kernel_cmd="ipython kernel -f {connection_file}"\ --name="Python 2.7" --cpus=2 --pe=smp --interface=sge
# Add an SSH connection to a remote machine running IJulia remote_ikernel manage --add \ --kernel_cmd="/home/me/julia-903644385b/bin/julia -i --startup-file=yes --color=yes /home/me/.julia/v0.6/IJulia/src/kernel.jl {connection_file}"\ --name="IJulia 0.6.0" --interface=ssh \ --host=me@remote.machine --workdir='/home/me/Workdir' --language=julia
# Set up kernels for your local virtual environments that can be run # from a single notebook server. remote_ikernel manage --add \ --kernel_cmd="/home/me/Virtualenvs/dev/bin/ipython kernel -f {connection_file}"\ --name="Python 2 (venv:dev)" --interface=local
# Connect to a SLURM cluster through a gateway machine (to get into a # local network) and cluster frontend machine (where the sqsub runs from). remote_ikernel manage --add \ --kernel_cmd="ipython kernel -f {connection_file}"\ --name="Python 2.7" --cpus=4 --interface=slurm \ --tunnel-hosts gateway.machine cluster.frontend
将安装内核规范文件,以便新内核出现在 笔记本中的下拉列表。remote_ikernel manage也有选项 显示和删除现有的内核。
连接复用< /H2>
当使用远程机器时,每个内核创建两个ssh 连接。如果你想减少,你可以设置自动 连接的多路复用。对于每台计算机,将配置添加到 ~/.ssh/config:
Host myhost.ac.uk ControlMaster auto ControlPath ~/.ssh/%r@%h:%p ControlPersist 1
这将创建一个主连接,当和 通过它把所有的东西都多元化。如果你有多跳,这就需要 为每个跃点添加。注意,出于安全考虑,空闲内核 在多路连接上,允许在没有 密码。
v0.4的更改
- Option ^{tt11}$. When given, the software will try to create an ssh tunnel through all the hosts before starting the final connection. Allows using batch queues on remote systems.
- Preliminary support for dealing with passwords. If a program is defined in the environment variable ^{tt12}$ it will be used to ask the user for a password.
- ^{tt13}$ can be used to override the command used to launch the interactive jobs on the cluster, e.g. to replace ^{tt14}$ with ^{tt15}$.
- Platform LSF support.
- The kernel json files are given unique names.
v0.3的更改
- Updated pip requirements to pull in the notebook package. Use an earlier version if you need to use IPython 3.
- Remote process is polled for output which will show up when ^{tt16}$ if used as a kernel option.
v0.2的更改
- Version 0.2.11 is the last version to support IPython notebook version 3. pip requirements enforce versions less than 4. Use a more recent version to ensure compatibility with the Jupyter split.
- Support for PBS/Torque through ^{tt17}$.
- Tunnels are kept alive better, if something is not responding try waiting 20 seconds to see if a tunnel had dies. (Tunnels no longer depend on pyzmq, instead they are launched through pexpect and monitored until they die.)
- ^{tt18}$ can be used to set ^{tt14}$ parameters or similar.
- ^{tt20}$ allows execution of an extra command on the remote host before launching a kernel.
- Better compatibility with Python 3.
- Kernel output on terminals with ^{tt16}$ option for debugging.
- Connect to a host with ssh, slurm, or local kernels.
- Changed prefix to ^{tt22}$.
- kernel_cmd now requires the ^{tt23}$ argument.
- ^{tt24}$ command to show existing kernels.
- Specify the working directory on the remote machine with ^{tt25}$.
- ^{tt26}$ is copied to the working director for systems where there is no access to the frontend filesystem.
- Added compatibility layer to get rid of Jupyter warnings.