How to Provision Google Colab GPUs From the Command Line
Learn how to install the Google Colab CLI, provision high-performance remote GPUs from your local terminal, and execute headless machine learning workflows.
The Google Colab CLI lets you connect local terminal environments directly to remote Google Colab runtimes. Released in June 2026, the tool bypasses the traditional web notebook interface to support headless execution and programmable infrastructure. This allows developers and AI agents to provision high-performance hardware, manage files, and run code entirely from the command line.
The CLI resolves the frequent session timeout issues associated with browser-based Colab sessions. It maintains drop-free connections for long-running machine learning pipelines, such as fine-tuning Gemma 4 adapters autonomously.
Installation and Setup
The Google Colab CLI is distributed as a Python-based tool. The official and recommended installation method relies on the uv package manager for speed and dependency isolation.
You can install the CLI globally on your local machine using the following command:
bash uv tool install git+https://github.com/googlecolab/google-colab-cli
Once installed, the CLI authenticates using your existing Google Cloud or Colab credentials. The tool falls back to standard pip environments if uv is not present on your system.
Hardware Provisioning
The most significant advantage of the CLI is the ability to request specific compute accelerators without navigating a graphical interface. You can request hardware directly via command flags when initializing a session.
The supported hardware tiers include NVIDIA T4, L4, A100, and H100 GPUs. For tensor-optimized workloads, the CLI also supports provisioning Google’s TPU v5e1 and TPU v6e1 accelerators.
Execution Modes
The CLI provides three distinct execution modes to handle different types of terminal workflows.
The colab exec command runs Python code on the remote runtime. It accepts input from standard input (stdin), local .py scripts, or standard .ipynb notebooks. This mode is designed for CI/CD pipelines and single-shot execution scripts.
For interactive debugging, the colab repl command launches a remote Python REPL session. This behaves exactly like a local Python shell but executes commands on the provisioned Colab virtual machine.
If you need full system access, the colab console command provides raw TTY shell access to the underlying VM. This allows you to inspect environment variables, monitor GPU utilization with nvidia-smi, or install system-level dependencies.
File Management and Integration
Managing data between your local machine and the remote runtime relies on native filesystem commands built into the CLI.
You can list remote directories using colab ls. Transferring datasets or model weights is handled by colab upload and colab download. For quick script modifications, the colab edit command opens remote files in your local $EDITOR, syncing changes back to the remote instance automatically.
The CLI also streamlines package management and cloud storage integrations. You can install Python dependencies directly on the remote instance using colab install, which leverages uv under the hood for fast resolution. If your datasets reside in cloud storage, the colab drivemount command links your Google Drive directly to the remote filesystem.
Automating Agent Workflows
Google designed the Colab CLI specifically to support highly programmable, multi-agent workflows. The terminal-first architecture allows tools like the Antigravity CLI or Claude Code to spin up remote instances, execute training routines, and tear down infrastructure autonomously in the background.
For local interface testing, the CLI includes a colab port-forward command. This enables port-forwarding from the remote VM to your local localhost. You can run web interfaces like Gradio or Streamlit on a remote A100 GPU while interacting with the application seamlessly in your local web browser.
To begin testing the tool, configure your local terminal environment with uv and test a simple colab repl session to verify your remote connection latency.
Get Insanely Good at AI
The book for developers who want to understand how AI actually works. LLMs, prompt engineering, RAG, AI agents, and production systems.
Keep Reading
Google's Agents CLI: A Terminal Path to Agent Platform
Google Cloud has introduced Agents CLI, a command-line tool that gives AI coding assistants a machine-readable interface for agent scaffolding and deployment.
How to Find GPU Gaps in PyTorch 2.12 With torch.profiler
Learn how to identify performance bottlenecks and idle GPU lanes using the native torch.profiler in PyTorch 2.12 across Blackwell and AMD hardware.
Cloudflare AI Gateway Ships Granular Dollar Spend Limits
The new spend limits feature lets organizations set hard dollar caps across multiple LLM providers and automatically route traffic to cheaper fallback models.
Google PHRM Achieves 6.09% MAPE in Passive Heart Rate Tracking
Google Research detailed a passive monitoring system that uses 8-second facial videos captured during routine smartphone unlocks to track resting heart rate.
4B Nemotron 3.5 Content Safety Resolves AI Moderation Black Box
NVIDIA released Nemotron 3.5 Content Safety, a 4B-parameter multimodal guardrail model that provides auditable reasoning for enterprise AI moderation.