-
-
Save whophil/5a2eab328d2f8c16bb31c9ceaf23164f to your computer and use it in GitHub Desktop.
# After Ubuntu 16.04, Systemd becomes the default. | |
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd | |
[Unit] | |
Description=Jupyter Notebook | |
[Service] | |
Type=simple | |
PIDFile=/run/jupyter.pid | |
ExecStart=/home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config=/home/phil/.jupyter/jupyter_notebook_config.py | |
User=phil | |
Group=phil | |
WorkingDirectory=/home/phil/Notebooks/ | |
Restart=always | |
RestartSec=10 | |
#KillMode=mixed | |
[Install] | |
WantedBy=multi-user.target |
I suggest putting the service file in /etc/systemd/system/
, not /usr/lib/systemd/system/
. The latter is only for system units installed from the distribution package manager, while the one in /etc
is for user-defined ones. It will make no difference in terms of functionality, but prevent conflicts with any package that might happen to install a jupyter.service
in the future. Reference: systemd.unit(5)
Thanks @sandtler, that is a good point - I have updated the instructions in the first comment.
I suggest putting the service file in
/etc/systemd/system/
, not/usr/lib/systemd/system/
. The latter is only for system units installed from the distribution package manager, while the one in/etc
is for user-defined ones. It will make no difference in terms of functionality, but prevent conflicts with any package that might happen to install ajupyter.service
in the future. Reference: systemd.unit(5)
If you need environment variables for Tensorflow GPU work, and .bashrc usually does the job for you, you need to somehow make those available to the Jupyter service, or else Notebooks that need the GPU won't be able to see it.
Not sure this is the best way, but it's the way I got it to work:
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
# ------------------------------------
Environment="PATH=/usr/local/cuda-10.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Environment="LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:/usr/local/cuda-10.1/lib64:usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
Environment="CUDA_HOME=/usr/local/cuda-10.1"
Environment="NUMBAPRO_NVVM=/usr/local/cuda-10.1/nvvm/lib64/libnvvm.so"
Environment="NUMBAPRO_LIBDEVICE=/usr/local/cuda-10.1/nvvm/libdevice/"
ExecStart=/home/phil/.local/bin/jupyter-notebook
User=phil
Group=phil
WorkingDirectory=/home/phil/z_Notebooks
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target
If encountering the following errors :
Check
/var/log/syslog
for a more verbose message. It may be thatSolution : use absolute paths in your config file.