Install & Run Jupyter Lab on Jetson TK1 as a Remote Machine
The reason behind I choose Jupyter Lab for developing Python in remote Jetson TK1 is because my VS Code wouldn’t establish Remote-SSH connection to that device. When establishing Remote-SSH connection, remote machine need to run VS Code Server (installed & run automatically when we try to connect to remote server).
At that moment, I realize that VS Code console log giving me error,
usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `CXXABI_1.3.9' not found
That’s means libstdc++
installed on Jetson TK1 too old and doesn’t have CXXABI_1.3.9
implemented. The Option is upgrading the Ubuntu OS used by Jetson TK1 to Ubuntu 16.04, but I think that is bad idea, because when ubuntu upgraded to the higher version, all the dependencies will be upgraded too and it’s too risky, for example CUDA wouldn’t run on that Ubuntu version.
So, the solution is to use another development tool that support Remote Development mechanism. There a lot of IDE offering this feature, but I choose Jupyter Lab, because it is simpler just by accessing through the browser and of course designed for Python development.
Prerequisites
- Install Python3.7 on Jetson TK1 by referring this article,
Install Jupyter Lab
- Install
jupyterlab-3.1.6
via pip (latest release when this article created),
python3.7 -m pip install jupyterlab --user
- Because we installed in
--user
space folder, we need to updatePATH
environment variable to add this following line at the end of~/.profile
,
export PATH=$HOME/.local/bin:$PATH
- Reload
~/.profile
,
source ~/.profile
Run Jupyter Lab & Set Password
- Test Jupyter Lab by run this command,
jupyter-lab --ip 0.0.0.0 --port 8888 --no-browser
- Then we can see Jupyter Lab URL,
- Copy that token part only, for example in above log is,
a3340460e6d29352c4f3cada984c8352b3a2c045f060fd0e
- Open the browser by accessing Jetson TK1 IP address in port
8888
,
http://<Jetson IP Address>:8888
- The result should look like this,
- Scroll down on that screen, then entering token to the token field in section Setup a Password, after that we can put our password to accessing Jupyter Lab latter,
- Then Jupyter Lab browser will be loaded ,
Run Jupyter Lab as a Service
- After we successfully run Jupyter Lab and set a password on that, now we need run Jupyter Lab automatically by service.
- Create a
jupyterlab
service,
sudo nano /etc/init.d/jupyterlab
- Insert below script,
#! /bin/sh
### BEGIN INIT INFO
# Provides: jupyterlab
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: jupyterlab service
# Description: jupyterlab service
### END INIT INFOexport PATH=/home/ubuntu/openssl/bin:/home/ubuntu/.local/bin:/usr/local/cuda-6.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
export LD_LIBRARY_PATH=/usr/local/cuda-6.5/lib::/usr/local/lib:/home/ubuntu/openssl/lib:/home/ubuntu/.local/libcase "$1" in
start)
su ubuntu -c "nohup /home/ubuntu/.local/bin/jupyter-lab --ip 0.0.0.0 --port 8888 --no-browser &"
;;
stop)
su ubuntu -c "nohup /home/ubuntu/.local/bin/jupyter-lab stop 8888 &"
sleep 2
;;
restart)
su ubuntu -c "nohup /home/ubuntu/.local/bin/jupyter-lab stop 8888 &"
sleep 2
su ubuntu -c "nohup /home/ubuntu/.local/bin/jupyter-lab --ip 0.0.0.0 --port 8888 --no-browser &"
;;
*)
echo "Usage: jupyterlab {start|stop|restart}" >&2
exit 3
;;
esac
- Make the script executable,
sudo chmod 755 /etc/init.d/jupyterlab
- Registering script into init script,
sudo update-rc.d jupyterlab defaults
- Reboot Jetson TK1
sudo reboot
- After Jetson TK1 up and running, we can directly access Jupyter Lab in the URL above,
- If you want to stop / start / restart manually, just entering this command,
- Start Jupyter Lab,
service jupyterlab start
- Stop Jupyter Lab,
service jupyterlab stop
- Restart Jupyter Lab,
service jupyterlab restart
Bonus
- Install Jupyter Lab Git extension,
python3.7 -m pip install jupyterlab-git --user
[UPDATE]
- If jupyter-lab failed to load
jupyterlab-git
extension like below,
- We need to force reinstall jupyter and jupyer-lab with the following command,
python3.7 -m pip install --upgrade --force-reinstall --no-cache-dir jupyter jupyterlab --user
- Then reinstall
jupyterlab-git
extension,
python3.7 -m pip install --upgrade --force-reinstall --no-cache-dir jupyterlab-git --user