This is how you can connect the Jupyter server that is running in your browser to your Genesis Cloud instance. Note that this tutorial is for single-user case. If multiple people want to access your instance, look into Jupyter hubs. At this point, you should know how to start an instance. If not follow this tutorial. Besides the command that starts the server, this tutorial works for both Jupyter Lab and Jupyter Notebook environment.


You are going to need a working installation of Jupyter on your cloud instance. All the preconfigured machine learning images are based on Anaconda virtual environments which include tons of machine learning and datascience tools including Jupyter, so you are ready to go out of the box. 

If you want to perform the installation yourself check the Installing Anaconda and Jupyter Notebook sections at the bottom.


Starting the Jupyter Notebook server

On your remote instance start a browserless Jupyter Notebook server using:

jupyter notebook --no-browser


If you want to start a Jupyter Lab server use:

jupyter lab --no-browser

By default this server is going to bind to port 8888, you can specify otherwise if you want, by using the --port=XXXX option. Once started the server will give you a lot of information about how to access it. Remember the two URLs at the bottom (here with the token XXXXXXXXXXXXXXXXXXXXXXXXX), they are going to become important in a second.

[I 09:03:52.329 LabApp] JupyterLab extension loaded from /home/ubuntu/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 09:03:52.329 LabApp] JupyterLab application directory is /home/ubuntu/anaconda3/share/jupyter/lab
[I 09:03:52.332 LabApp] Serving notebooks from local directory: /home/ubuntu
[I 09:03:52.332 LabApp] The Jupyter Notebook is running at:
[I 09:03:52.332 LabApp] http://localhost:8888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[I 09:03:52.332 LabApp] or http://127.0.0.1:8888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[I 09:03:52.332 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 09:03:52.335 LabApp]

To access the notebook, open this file in a browser:
file:///home/ubuntu/.local/share/jupyter/runtime/nbserver-2964-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
or http://127.0.0.1:8888/?token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX


Forwarding ssh traffic

On your local machine forward the ssh traffic from the remote host, specifying the IP of your instance.

ssh -CNL localhost:8888:localhost:8888 ubuntu@<INSTANCE-IP>


Done!

You can now access the Juypter Notebook/Lab by pasting the URL that you got when starting the server into the browser of your local machine.



Installing Anaconda and Jupyter

If you are using one of the preconfigured machine learning images, Anaconda and Jupyter are already installed and this section is not necessary. 

If your are starting from a clean slate and want to install Anaconda by hand, you first have to get the link to your desired Anaconda Version here (make sure it's 64bit x86 version) and then download it to your instance using

wget <link-to-your-Anaconda-version>

This is going to download a installation script with a name similar to Anaoconda3-<year>.<month>-Linux-x86_64.sh. Give this script executable privileges and run i using:

chmod +x <path-to-script>
<path-to-script>

You should have anaconda installed after a few prompts. This may require you to log off and on again. You might want to activate a separate environment, because managing python environments is a messy business. Now install Jupyter.

conda install -c conda-forge jupyterlab