Wednesday, 7 May 2014

Setting up a single node IPython Notebook

Install IPython

  After installing IPython by sudo apt-get install ipython-notebook, we can follow the instruction here to setup a public notebook. The steps are below:

note: this works for my old desktop
$ sudo apt-get install python-pip
$ sudo pip install ipython[all] --upgrade

1. create a certificate
openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

2. generate a hashed password in IPython environment
In [1]: from IPython.lib import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:xxx:yyy'

3. create a notebook profile
ipython profile create wasit

4. edit /home/ubuntu/.ipython/profile_wasit/ by the following code:
c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.certfile = u'/home/ubuntu/.ipython/profile_wasit/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:xxx:yyy'
c.NotebookApp.port = 8888
c.NotebookApp.enable_mathjax = True

5. then we can start the notebook by going to particular directory and run the script
$ipython notebook --profile=wasit
$ipthon notebook --certfile=mycert.pem

However, the session will be terminate and we no longer run the job. In order to redirect the terminal output and keep the job run after terminating ssh, we should put the command in the 5th step in and run this
$ nohup ./ </dev/null &