Use Jupyter Notebook on my local computer to run c

2019-04-10 01:45发布

问题:

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.

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

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

conda install jupyter

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

jupyter notebook --no-browser

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.

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).

回答1:

If you want to access Jupyter/Ipython notebook running on a VPS remotely, I wrote a tutorial on the digital ocean community site.

As shown in the guide, after installing and running Ipython Notebook using command line on the server, you can connect to the notebook using SSH tunnelling with Putty (on windows) or the ssh -L command on Unix-like systems (ie Mac and Linux)



回答2:

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

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

Copy and paste the URL in your local machine browser.