How do I add a kernel on a remote machine in IPython (Jupyter) Notebook?

半腔热情 提交于 2019-11-26 20:15:16

问题


Dropdown menu in the top-right of the UI on a local machine (PC):

Kernel-> 
    Change kernel->
        Python 2 (on a local PC)
        Python 3 (on a local PC)
        My new kernel (on a remote PC)

回答1:


IPython use kernel is a file in ~/.ipython/kernel/<name> that describe how to launch a kernel. If you create your own kernel (remote, or whatever) it's up to you to have the program run the remote kernel and bind locally to the port the notebook is expected.




回答2:


The IPython notebook talks to the kernels over predefined ports. To talk to a remote kernel, you just need to forward the ports to the remote machine as part of the kernel initialisation, the notebook doesn't care where the kernel is as long as it can talk to it.

You could either set up a wrapper script that gets called in the kernel spec file (https://ipython.org/ipython-doc/dev/development/kernels.html#kernel-specs) or use a module that can help you set up and manage different kinds of remote kernels: (pip install remote_ikernel; https://bitbucket.org/tdaff/remote_ikernel).

If you are using remote_ikernel, and have ssh access to the machine, the following command will set up the entry in the drop down list:

remote_ikernel manage --add \
    --kernel_cmd="ipython kernel -f {connection_file}" \
    --name="Remote Python" --interface=ssh \
    --host=my_remote_machine



回答3:


Remote jupyter kernel/kernels administration utility (the rk): https://github.com/korniichuk/rk

  1. Install the rk from GitHub:

    $ sudo pip install git+git://github.com/korniichuk/rk#egg=rk

  2. Setup SSH for auto login without a password:

    $ rk ssh

  3. Install a template of a remote jupyter kernel:

    $ rk install-template

  4. Change the kernel.json file:

    $ sudo gedit /usr/local/share/jupyter/kernels/template/kernel.json

For example from remote_username@remote_host to albert@192.168.0.1.

Click: Quickstart and YouTube video (less than 3 min).



来源:https://stackoverflow.com/questions/29037211/how-do-i-add-a-kernel-on-a-remote-machine-in-ipython-jupyter-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!