11 December 2022

A Python Jupyter Notebook environment (JupyterLab) for daily use, flexible, reliable, affordable and customizable.


For quite some time I was using Colab until I could not rely on it anymore (suddenly, within seconds/minutes, the session would stop  and all the variables with it) even if I had purchased 'compute credits'.

At that point I started looking for alternatives:
- Paperspace (as reliable as 1+ year ago)
- Sagemaker Notebook
- Vertex AI Notebook (my last discovery)
among others.

Vertex and Sagemaker are similar, and deeply hidden within the many Google/AWS services.

With Vertex I can get a VM
- With JupyterLab preconfigured
- Flexible CPU/RAM/Disk (you can change that any time)

Trick0: Pricings vary a lot whether it is managed / user-managed and the region-sub_region you place it on. The best way to see the pricing is to create both and get the pricing estimate. The price per region can be seen just selecting the regions.


Well, and now, let's go to the practical stuff that I wish someone would have told me.

Starting the VM
On the Vertex AI page, find your VM and click "Start". Simple.




Then click on "Open Jupyterlab".

Trick1: Find how to 'detach' that Jupyterlab window to have more space (depends on your browser). In a browser, a web detached is a web without seeing the browser (almost like fullscreen).


Trick2: The url is permanent, so you can save it on a script/shortcut and open+detach all at once. Mine is 


Note: you can create another script for the url of the ssh session (see below about the ssh).


If you click "View VM details" you get here


 

Now click on SSH > "Open in browser window". You can also 'detach' that.

Trick3: All the windows we have open (Jupyterlab and ssh) remain valid even after poweroff + poweron. That is, you can just leave them there when you poweroff the VM and come back where you left after poweron.

Trick4: Read about Jupyterlab restore session. It has to do with the url.

I found out that
a) If the Jupyterlab window stops working, I run the command in Trick2 and get it back as it was. 
b) If a) doesn't work (I don't get my 'main' session), I run the script again and that 3rd window does get back my session. Close the 1st one (the one that seems dead) and the 2nd one if you don't need it.


So by default this is the environment I have (all detached).
- 1 Jupyterlab with the 'main' session (the permanent one)
- 2 ssh sessions

 Windows on the windows bar of the OS (Operating system)





You can move the 2 ssh around as needed (the one with logs sometimes is 'on top' permanently).

To get colorful logs I use this command (you need to install grc):
# grc tail -f /path/to/file

You can read the logs from Jupyterlab, but I find it more flexible from ssh (plus the colors).

Sometimes I open a 2nd Jupyterlab to inspect some other files (not to work on notebooks) and close when not needed anymore (so the 1st one keeps being the 'main' one).


Trick5: When you need to stop, save all files and just run from one of the SSH sessions
# sudo shutdown -h now
And walk away. Don't need to go to the screen where you clicked "Start".

Remember, there is no need to close these 3 windows. You can "reuse" them the next day (after poweron, of course).


I hope it helps you (especially if you need to move away from Colab).

Too Cool for Internet Explorer