Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

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

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)
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...