News icon

Kimi K3 is now available on Runpod

How to Connect Google Colab to Runpod

Prefer Google Colab's interface? This guide shows how to connect Colab notebooks to Runpod GPU instances for more power, speed, and flexibility in your AI.

How to Connect Google Colab to Runpod

It looks like some of you are used to Google Colab's interface and would prefer to use that over the command line or JupyterLab's interface. Well, good news, you can connect Colab to use your own custom compute instead of the GPU that they assign to you! Unfortunately, Google won't let you connect directly to a remote instance, but with a few simple steps, you can get around it by using your local machine to forward the remote port. Sound complicated? It's not too bad! We can get this going together in a few minutes :)

Back Your Favorite Google Colab Notebooks with Runpod GPUs

First thing's first, start a Runpod instance. For this guide, I'm going to use the Runpod pytorch launch template, but you can use any template that you want. Warning, custom images may require more dependency installs to make it work! Make sure that your instance has "SSH Terminal Access" checked. If you want to deploy on community cloud, you need to find a TCP enabled instance through the "Browse" menu.

Runpod pod configure step for an RTX A6000 with PyTorch template, SSH and Jupyter Notebook options enabled
Runpod pod management menu with Edit Job highlighted on a running PyTorch pod card

Put the following into your "Docker Command" field. While you are here, copy the JUPYTER_PASSWORD env variable value (in this case it's 51as1vrmd5ne4jmwjwha). We'll need this password later to authenticate. Hit Save to start your instance with the new command.

Runpod edit pod dialog with a Docker command enabling jupyter_http_over_ws and environment variables set

This should work for any Runpod standard template. All it does is enable the Jupyter extension that enables http over websockets before starting Jupyter Lab.

Once your instance starts, start an SSH tunnel with port forwarding. You can do this by copying the last command in your "Connect" menu and then appending -L 8888:localhost:8888.

Runpod connection options modal listing SSH commands for basic terminal and SSH over exposed TCP

In this case the full connection command you want to run is:

This connects you to the pod and forwards 8888 within the pod to 8888 on your local machine. Google Colab needs this to connect to the pod, as it connects through your machine to do so.

Open up your favorite notebook in Google Colab. You will see a "Connect" button/dropdown in the top right corner.

Google Colab notebook toolbar showing the Connect button for attaching a runtime

Click on it and select "Connect to a local runtime". This will present you with a field to fill in the address of the local runtime. This is where that JUPYTER_PASSWORD you copied earlier comes in handy. Put the password you copied after the ?token= and then hit connect. If you forgot where you put that password, you can always go back to the "Edit Job" menu and find it there. Be sure to hit Cancel instead of saving, as it will reboot your pod if you save it!

This is what it looks like for this specific pod. Remember to replace this with your own password!

Google Colab local connection settings dialog with a Jupyter backend URL and token entered

If all goes well, then you should now be connected to your pod through Colab! You should see a Connected(local) in green in the top right corner.

I hope that this helps anyone that wanted the power of Runpod with the familiar UI/UX that Google Colab provides. Happy exploring!

Author profile: Zhen Lu

Related articles

View All
GPU memory math for full-parameter fine-tuning: sizing VRAM before you rent

GPU memory math for full-parameter fine-tuning: sizing VRAM before you rent

A practical guide for accurately calculating the VRAM requirements for full-parameter model fine-tuning, explaining why standard inference-based rules of thumb are insufficient and offering equations to help users properly size their compute resources.

All
Make the model yours

Make the model yours

Customizability is the most underrated idea in AI right now. Runpod CEO Zhen Lu on why a model tuned on your data beats a bigger one on the job you actually have.

All

Build what’s next.

Build, train, and scale AI workloads on Runpod with cloud GPUs, Serverless, and Clusters.

Star field background