在我的本地计算机上使用Jupyter Notebook在远程计算机上运行代码 [英] Use Jupyter Notebook on my local computer to run code on a remote computer

查看:240
本文介绍了在我的本地计算机上使用Jupyter Notebook在远程计算机上运行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Jupyter Notebook进行生物信息学分析,我很喜欢.但是,只有当我在个人计算机上运行它时,它才能真正发挥作用.但是,我经常使用具有多个内核的远程计算机进行分析,以减少处理时间.我希望能够在我的个人计算机上使用Jupyter Notebook界面,而一切实际上都在远程计算机上运行.我通常通过ssh访问外壳中的远程计算机来执行此操作,并在命令行中执行所有命令.我很想从个人计算机上的Jupyter笔记本而不是从个人计算机的外壳中执行此操作.我在远程计算机上没有sudo访问权限,这一点很重要.

I use Jupyter Notebook to run bioinformatic analyses, and I love it. However, it only really plays nice when I run it on my personal computer. However, I regularly do analysis using a remote computer with multiple cores to reduce processing time. I'd like to be able to use the Jupyter Notebook interface on my personal computer while everything is actually running on the remote computer. I generally do this via ssh access to the remote computer within the shell and execute all commands at the command line. I'd love to do this from the Jupyter notebook on my personal computer, rather than from the shell on my personal computer. It is relevant that I don't have sudo access on the remote computer.

到目前为止,我已经像这样在远程计算机上安装了minicondajupyter notebook:

So far, I've installed miniconda and jupyter notebook on the remote computer like this:

wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh

一旦正确安装了conda,我将通过miniconda在以下行中安装jupyter笔记本:

Once conda is installed properly, I install jupyter notebook via miniconda with this line:

conda install jupyter

这将成功安装.然后,我可以使用以下行在远程计算机上启动jupyter笔记本会话:

This installs successfully. I can then start a jupyter notebook session on the remote machine with the line:

jupyter notebook --no-browser

到目前为止,太好了.我的下一个问题:如何将本地Jupyter笔记本连接到远程计算机,以便可以使用本地Jupyter笔记本在远程计算机上执行命令? 此处有一些文档,但是我已经尝试了好几个小时了,但没有成功.

So far, so good. My next question: How do I have my local jupyter notebook connect to the remote machine, so that I can execute commands on the remote machine using my local jupyter notebook? There is some documentation here, however i have been trying different things for hours, but have failed to succeed.

鉴于我已经走了这么远,有人可以给我一个简单的方法来连接到我的远程服务器吗?我觉得这应该只是在本地Jupyter笔记本中输入URL地址和密码的问题(所有这些操作都非常简单,只需通过Shell中的ssh即可).

Can anyone give a straight forward method to connect to my remote server, given that I am this far along? I feel like it should just be a matter of entering url addresses and passwords into my local Jupyter notebook (all of this is so easy via ssh in the shell).

推荐答案

请按照以下步骤操作:
在远程计算机上启用端口转发

Follow the steps below:
Enable port forwarding on remote machine

ssh -N -f -L 127.0.0.1:8898:127.0.0.1:8898 user@remote-machine.com

对您的远程计算机执行ssh,然后在远程计算机上运行以下命令

Do ssh to your remote machine and then run following command on remote machine

jupyter-notebook --no-browser --port=8898

您将看到一些如下所示的内容

you will see some thing as shown below

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
http://localhost:8898/token=eaf2f51f9c053f43d8bd093e76f0cc6301b545549c998fa2&token=eaf2f51f9c053f43d8bd093e76f0cc6301b545549c998fa2

将URL复制并粘贴到本地计算机浏览器中.

Copy and paste the URL in your local machine browser.

这篇关于在我的本地计算机上使用Jupyter Notebook在远程计算机上运行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆