ipython notebook as service via systemd on ubuntu 16.04 with theano gpu support

I was re-purposing my old desktop for machine learning with gpu support for Theno and Keras, I ran into several issues and ended up writing some code to workaround some of them and make others easier and more manageable. Someday I will write a more detailed series of articles on how I did that and what I learnt in the process, but today I just wanted to document the last steps I ran into when trying to convert my anaconda based adhoc ipython notebook server into a persistent service.

The initial logic came from, this blog post. However I ran into several issues, first the config is for native ipython not anaconda based ipython and it did not pull in env variables need for theano to pull in the nvc compiler optimizations needed for gpu support.

Here is the final config of the file /etc/systemd/system/ipython-nb-srv.service

Description=Jupyter Notebook Server



After this you do

systemctl daemon-reload
systemctl enable ipython-nb-srv
systemctl start ipython-nb-srv

Some of the previous high-level steps are

  1. Install cuda packages for ubuntu
  2. Install Anaconda
  3. Create a py env
  4. Install the required packages (Theano, keras, numpy, scipy, ipython-notebook etc)
  5. Create .theanorc to make sure theano uses gpu
  6. Create .ipython notebook profile to run as server
  7. Create ipython notebook server service
  8. Enjoy your ipython notebooks from chomebook or windows machine 🙂

Leave a Reply