-
Notifications
You must be signed in to change notification settings - Fork 0
Jupyter
Jupyter notebooks are a great way to keep code organized and documented. Notebooks have individual cells, which can be in the kernel language (in this case, python), or in markdown (the language also used by github). A single cell can be run by hitting command-enter or shift-enter (the latter automatically advances to the next cell). A cheat-sheet for Markdown syntax can be found here. Note that markdown cells support LaTeX equations. To start jupyter, type
jupyter notebook
on your command line. This will open a browser window, from which you can navigate to the notebook of choice.
To exit jupyter, hit ctrl-c twice in the terminal from which you started it. Not doing so will slow down the computer you're running on.
On unix computers, jupyter sometimes only works with chrome, so you need to start it with
jupyter notebook --browser="google-chrome"
Running jupyter remotely from your own laptop can be quite slow. In this case, you can speed things up significantly by running it remotely, but the browser locally:
Requirements
Jupyter notebook installed in both the local_host and remote_host
Procedure
- Login to the remote host:
local_host$ ssh -L localhost:8888:localhost:8889 usernm@remote_host
If you get a message such as cannot listen to port: 8888, you can choose a different port number.
-
cd
to the Directory where you have want to create your .ipynb files and start Jupyter notebook at port 8889 on remote host without a browser:
remote_host$ jupyter notebook --no-browser --port=8889
- Go to a browser in the local machine and in the address bar type:
localhost:8888/
- If a token is requested then copy the token from the URL printed by the Jupyter notebook call in the terminal. You can also use the following command to view the tokens currently open:
In a separate session of ssh type:
remote_host$ jupyter notebook list
This should give an output like:
Currently running servers:
http://localhost:8889/?token=fccb1b2c8b7157de14466993c5d374c2933f6a4a3e284c53
Copy and paste the token. You should be able to run jupyter notebook faster and on the local browser without window forwarding.
Side effects
Once a port is assigned to remote_host it is no longer available to the local_host. So in the above example port 8888 is now binded to the remote host. This means that a local jupyter notebook cannot be started with the same port which also happens to be the default port.
Hence the following command may not work on the local machine:
local_host$ jupyter notebook
The workaround is very similar to the example above i.e. using a different port available.
local_host$ jupyter notebook port=8889
Currently, the only way I know to reset all ports is to reboot the local machine.
- Syllabus
- Schedule
- Stone Edge Observatory
Labs and Write-ups
- Lab Report Guidelines
- Lab1
- Lab2
- Lab3
Computing Resources