Google Colab in VS Code: A Deep Dive into the New Extension
A comprehensive guide to leveraging Google's cloud computing prowess directly within your favorite local editor.

I'm a Machine Learning Engineer passionate about building production-ready ML systems for the African market. With experience in TensorFlow, Keras, and Python-based workflows, I help teams bridge the gap between machine learning research and real-world deployment—especially on resource-constrained devices. I'm also a Google Developer Expert in AI. I regularly speak at tech conferences including PyCon Africa, DevFest Kampala, DevFest Nairobi and more and also write technical articles on AI/ML here.
For years, a subtle but significant divide has existed in the workflow of millions of developers, data scientists, and AI researchers. On one side stood Visual Studio Code, the fast, lightweight, and endlessly customizable code editor beloved by the global developer community. On the other was Google Colab, the go-to platform for seamless access to powerful compute resources like GPUs and TPUs, simplifying the process of writing, executing, and collaborating on code. The workflow often involved a cumbersome dance between a customized local VS Code environment for project development and a separate, web-based Colab interface for training and inference.
Responding to years of passionate community requests manifested in blog posts, forum threads, and creative GitHub workarounds, Google has officially bridged this gap. Today, we are thrilled to explore the new Google Colab extension for Visual Studio Code, a tool that promises the best of both worlds. This article provides a detailed, technical tutorial on how to install, configure, and harness the power of this game-changing extension, transforming your local VS Code into a control room for Google’s heavy-lifting cloud infrastructure.
The Best of Both Worlds: Unifying Local IDE and Cloud Compute
The core value of the Colab extension is its ability to meet developers where they are. It acknowledges that while Colab’s simplicity is a major strength, many users crave the advanced features of a full-fledged IDE for larger projects and complex workflows.
For VS Code Users: The primary advantage is the ability to connect local
.ipynbnotebooks to high-powered Colab runtimes. This means you can continue using your familiar, highly customized editor while seamlessly accessing premium GPUs and TPUs, including those available through Colab Pro subscriptions, without leaving your local environment.For Colab Users: This integration supports the common practice of working on notebooks that are part of a larger project or Git repository. It empowers users who need more robust IDE features—such as superior code completion, version control, and advanced debugging—by pairing the simplicity of Colab's provisioned runtimes with the prolific VS Code editor.
Essentially, this move bridges the gap between code productivity and cloud compute scalability, eliminating the need to switch tabs, export notebooks, or manage credentials across different platforms.
Getting Started: A Step-by-Step Guide
You can get up and running with the Colab extension in just a few clicks. The setup is designed to be intuitive and fast.
Step 1: Install the Colab Extension
First, you need to add the extension to your VS Code installation.
Open the Extensions view from the Activity Bar on the left side of your VS Code window (or press
Ctrl+Shift+X).In the marketplace search bar, type
Google Colab.Click Install on the official extension published by Google.
If you do not already have it, the installer will prompt you to install its required dependency, the official Jupyter extension.

Step 2: Connect to a Colab Runtime
Once installed, you can connect any local notebook to a Colab runtime.
Create a new notebook (
.ipynbfile) or open an existing one in your local VS Code workspace.To select the execution environment, you can either run a cell, which will prompt you to choose a kernel, or click the Select Kernel button in the top-right corner of the notebook interface.
From the dropdown menu, choose Select Another Kernel...
Click on the Colab option. You will be prompted to sign in with your Google account.
After signing in, you can choose to create a New Colab Server or connect to an existing one you may have running. For your first time, you will create a new one.

Your local notebook is now powered by a Google Colab runtime! You can give your Colab server a name so that it can be easily referenced and reused in the future.
Step 3: Select Your Compute Resources
The true power of this extension lies in accessing specialized hardware. The available accelerator options and memory limits are determined by your Google Colab subscription plan.
Free Tier: Users have access to NVIDIA T4 GPUs and TPU v5e accelerators.
Colab Pro Tier: Subscribers gain access to more powerful hardware, such as premium GPUs like the NVIDIA A100.
After connecting to the Colab kernel, you can select your desired hardware accelerator for the session.

Practical Examples — Beyond the Basics
To truly appreciate this new workflow, let's move beyond simple demonstrations. Here are two original, real-world scenarios that are impractical on a standard local machine but become trivial with the Colab extension.
Example 1: GPU-Accelerated Big Data Analysis with RAPIDS cuDF
The Challenge: You need to analyze a large CSV file (several gigabytes) containing millions of records. Using a standard library like Pandas on a CPU can be painfully slow, with simple grouping and aggregation operations taking minutes to complete.
The Solution: We'll use RAPIDS cuDF, a GPU-accelerated DataFrame library with a Pandas-like API. By running this in VS Code connected to a Colab GPU, we can perform the analysis in seconds. RAPIDS cuDF is now pre-installed in Colab GPU runtimes, making this seamless.

The Result:
The complex aggregation on 3,066,766 rows of data completes in just 0.3070 seconds. This incredible speed, demonstrated in the output below, transforms what would be a coffee-break task on a CPU into an interactive, real-time query. This showcases a real-world data engineering task made efficient and seamless, all within the comfort of VS Code.

The Code:
You can find a copy of the corresponding Colab workbook for this example here.
Example 2: Creative AI — Generating Art with Stable Diffusion
The Challenge: Text-to-image models like Stable Diffusion are computationally expensive and require significant GPU VRAM, making them inaccessible to users without high-end local hardware.
The Solution: We'll use the Hugging Face diffusers library to run a Stable Diffusion pipeline on our Colab GPU kernel. This allows us to generate high-quality images from text prompts directly inside a VS Code notebook.
Install required libraries We need diffusers, transformers, and accelerate for this task.

Set up the Stable Diffusion Pipeline This code downloads the pre-trained model weights and prepares the pipeline for inference on the GPU.

Generate an Image Define your creative prompt and let the model generate an image.

The Result: Within a minute, a high-resolution, AI-generated image appears directly in your VS Code notebook output. This showcases how the extension democratizes access to powerful generative AI models, enabling creative experimentation without the need for a dedicated local GPU.

The Code:
You can find the corresponding Colab notebook for this example here.
Advanced Tips and Current Limitations
To get the most out of the extension, keep these points in mind:
File Management: You are working on a remote Colab file system. Use commands like
!ls -lor VS Code's built-in file explorer to see files generated in your runtime. To persist your work, consider mounting your Google Drive:from google.colab import drive drive.mount('/content/drive')Secrets Management: The web UI's native secrets manager is not yet available. For securely handling API keys, use the file-upload workaround to upload a
.envfile, as detailed in the source articles.Session Lifetime: Remember that Colab runtimes are ephemeral. They will disconnect after a period of inactivity (typically 90 minutes for free-tier users) or if you exceed the maximum session duration (12 hours). Save your work frequently.
The Bigger Picture: What's Next?
As a newly released tool, the Colab extension is still in its early stages, and some limitations exist. As noted, certain web-UI-specific functions like the secrets manager are not yet implemented. However, Google has positioned this release as a "launchpad," signaling a commitment to bringing even more of Colab's functionality to developers everywhere.
This launch also places Google in a fascinating strategic position, turning VS Code into a key battleground for AI developer mindshare. By bringing its powerful code execution engine into the same interface where tools like GitHub Copilot excel at code generation, Google is challenging the AI-assisted developer landscape.
For developers, this rising competition is a net positive. It promises a future where the lines between code generation and execution blur, and where powerful, integrated, and accessible AI tools become a fundamental component of the editor itself.
Conclusion
The new Google Colab extension for VS Code is more than just a convenience; it's a transformative tool that unifies the best of local development with the power of cloud computing. It empowers developers and ML engineers to harness free GPUs and TPUs directly within their preferred editor, streamlining workflows and accelerating innovation. While still in its early stages, the extension represents a significant step forward in making AI and machine learning development more accessible and productive. The future looks bright, and it runs on a seamless connection between your local machine and the cloud.




