Upgrade Colab with More Compute

How to upgrade collab with more calculations


In a previous episode of AI Adventure, we looked at Colab as a great way to get started in the world of data science and machine learning. But there are some models that should run longer (Colab instance will reset after several hours), you want to get more memory or GPUs than provided for free.


The question then becomes: how can we hook up the frontend of Colab with more compute power? We're using Google Cloud Platform's Deep Learning V VMs to power your collaborative environment. After a while, we looked at how to create Deep Learning V VMs with a choice of machine learning frameworks. We will use that example today and connect the collab to it so that we can use the resources in that machine.





To get started, we should definitely build our VM, and make it big! Go to Cloud Marketplace and find Deep Learning V VM and choose it. I'm going to call minecolab-vm. And for a better solution, let's include 1 16 CPU with 160 GB memory! And for the GPU, I choose the V100s, and put them among the two! Now we are really cooking!

We are waiting for JupyterLab to start, let's talk about how to get Colab to talk to your VM. There are two tricks we are going to use, which together make this connection possible. The first is the fact that Colab can connect to a local runtime. So if you have a local Jupiter notebook server running, you can use Colab as a frontend on that server, rather than a normal Jupiter notebook frontend. You can access this option by clicking the drop-down menu in the upper right corner of the column and selecting "Connect to local runtime".

Select "Connect to local runtime" to connect to the local Jupiter server

Select "Connect to local runtime" to connect to the local Jupiter server instead of using the default Google-hosted runtime.

The second trick we will take advantage of is that we can forward the port to the newly created Deep Learning VM so that it can be accessed from our local machine. You can do this with this command (just change Colab-VM for your VM name):

gcloud Compute ssh Colab - vm - -L 8080: Local Host: 8080

Make sure this is from your local terminal, Cloud Shell. In this particular case, we want to forward the port to our local machine, running our command in the cloud shell does not achieve our goals. Additionally, note that the command features a double-dash: -. This command sends a "next layer" of commands to all who come after it, so to speak. In this case, it means that -L 8080: Localhost: 800 is given in the g0 ssh command, rather than gcloud compute. It maps ports from a virtual machine to configure what should happen on your local machine.




Having its own port-forward means that we can access the Jupiter server from the local frontend, which you can do by going to http: // localhost: 8008080. But if we open Colab and tell it to connect to our "local" runtime, the local runtime it sees is actually port-forwarded from DipLearn V VM! And so the two were paired.

In my V100 powered Collab example, I can run Nvidia
-smi to confirm that yes, we have two V100 GPUs powering this example:

Image for post

2x V100s listed as GPU0 and GPU1

So now you understand how Collab and DeepLearn VVMs can work together, and how to get your setup, how both frontends look according to the changes you want, and which backend system is running it. For example, develop early against your local backend, and when you want to gain more power, you can connect it to your Deep Learning VM and run a large training work.




How do you set up your data science environment, and how do you allow it to change, flex, and grow as needed? Share your perspective in the comments below!

For now, go to Deep Learn V VM and try connecting it to your Colab notebook!

Get started with Colab now → https://goo.gle/2JE3Lui


TPU resources →  https://goo.gle/2WCclk4 

Deep Learning VMs Documentation: https://goo.gle/2Z3jCWx


Comments