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
[Unit] Description=Jupyter Notebook Server [Service] Type=simple Environment="PATH=/home/ipynbusr/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" ExecStart=/home/ipynbusr/anaconda3/bin/jupyter-notebook User=ipynbusr Group=ipynbusr WorkingDirectory=/home/ipynbusr [Install] WantedBy=multi-user.target
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
- Install cuda packages for ubuntu
- Install Anaconda
- Create a py env
- Install the required packages (Theano, keras, numpy, scipy, ipython-notebook etc)
- Create .theanorc to make sure theano uses gpu
- Create .ipython notebook profile to run as server
- Create ipython notebook server service
- Enjoy your ipython notebooks fromÂ chomebook or windows machine 🙂