Skip to content
FossShelf
Home / Categories / For Engineers

Google Colab Cli

Run Colab GPU and TPU jobs from the terminal, no browser needed

Replaces Google Colab, Modal

2.50K starsApache-2.0reviewed 17 Nov 2026last commit 15 Nov 2026
Screenshot of Google Colab Cli

Who it's for

ML engineers running training jobs in CI/CD pipelines

`colab run --gpu A100 train.py` provisions a fresh runtime, executes the training script, and tears down the VM on completion. Output files can be retrieved with `colab download` before teardown, or the session kept with `--keep` for inspection after the job finishes.

Your CI/CD environment needs GPUs that run on private infrastructure or specific cloud regions. Colab hardware runs on Google's infrastructure only; a cloud provider's native GPU instances or a self-hosted cluster serve that need.

Data scientists automating notebook execution

`colab exec -f report.ipynb` executes a local notebook against the remote Colab kernel, writing outputs to `report_output.ipynb`. Combined with `colab drivemount`, this lets you run Google Drive-backed notebook pipelines from a cron job or shell script without opening a browser.

Your notebooks rely on local filesystem paths or localhost services. The notebook runs on a remote VM, so local file paths and local network services are not reachable from within the executed notebook.

AI developers integrating Colab compute into agent workflows

The CLI's non-interactive execution modes (piped stdin to `colab exec`, one-shot shell commands via `colab ssh -s NAME, CMD`) make it usable from automated agent frameworks. The `--auth adc` flag integrates with Application Default Credentials for agents already using GCP authentication.

Your agent needs high-concurrency GPU sessions. The free and Pro tiers have compute unit limits; high-concurrency GPU workloads may exceed quota before the job finishes.

Researchers using Colab Pro subscriptions more fully

Colab Pro and Pro+ subscribers get priority access to T4, L4, A100, and TPU runtimes that are often unavailable on the free tier. The CLI makes those resources usable in scripts and pipelines, not just the browser notebook editor, extending the practical scope of the subscription.

You are on the free Colab tier and need reliable GPU access. Free tier runtime availability is not guaranteed; the CLI exposes the same availability constraints as the web interface.

The problem

Running machine learning training jobs on remote GPU hardware typically means opening a browser, working inside a Jupyter notebook interface, and manually copying output files back to local storage. This workflow prevents automation: a CI/CD pipeline cannot open a browser tab, a training script cannot call a Colab notebook directly, and an AI agent cannot interact with a browser-based IDE. The specific cost is paid compute going unused. Many ML engineers have a Google Colab Pro or Pro+ subscription, which grants priority access to T4, L4, A100, and TPU runtimes. Those runtimes are only accessible through the web interface by default, leaving automation use cases unsupported and forcing engineers to look at additional billing relationships with separate GPU compute services when their Colab subscription already covers the hardware.

How it works

Ephemeral job runner with auto-teardown

`colab run --gpu T4 train.py` provisions a fresh VM, executes the local script with forwarded arguments, retrieves output files, and terminates the VM automatically on completion. No session lifecycle management code is needed in the script itself, and the entire job runs in one shell command.

GPU and TPU runtime provisioning

Supported accelerators include T4, L4, G4, H100, and A100 GPUs, plus v5e1 and v6e1 TPU runtimes. Run `colab new --gpu A100` or `colab new --tpu v6e1` to provision the specific hardware the job requires. Machine shape (standard or high-RAM) is selected with `--high-mem` and shown in `colab sessions` and `colab status`.

Direct file operations on the remote VM

Upload, download, list, delete, and in-place edit files on the runtime with `colab upload`, `colab download`, `colab ls`, `colab rm`, and `colab edit`. The edit command opens the remote file in your local `$EDITOR`, writes changes back, and requires no manual upload step beforehand.

SSH shell and interactive REPL access

`colab ssh` opens a full SSH shell to the runtime over WebSocket, with optional `ProxyCommand` mode for IDE remote-dev connections. `colab repl` starts an interactive Python session on the kernel. Both commands support piped stdin for non-interactive pipeline use.

Session history export to Jupyter and Markdown

`colab log` exports the session's execution history as a standard `.ipynb` notebook, Markdown, plain text, or structured JSONL. This lets you archive every run's inputs and outputs without manually downloading the notebook from the Colab web interface.

Google Drive mount and GCP credential forwarding

`colab drivemount` mounts Google Drive at `/content/drive` on the VM, matching the standard Colab notebook path. `colab auth` authenticates the runtime for GCP services including BigQuery and Google Cloud Storage, so existing GCP workflows run on Colab hardware without credential reconfiguration.

Features

  • Ephemeral job runner with auto-teardown
  • GPU and TPU runtime provisioning
  • Direct file operations on the remote VM
  • SSH shell and interactive REPL access
  • Session history export to Jupyter and Markdown
  • Google Drive mount and GCP credential forwarding

How to install

Install the CLI on Linux or macOS using pip or uv.

uv tool install google-colab-cli
pip install google-colab-cli

Recommended for this setup

Strengths

  • Officially maintained by the Google Colab team: The repository is under the `googlecolab` GitHub organization, the same team that builds the Colab product. For a CLI that authenticates against Google's production infrastructure, official maintenance matters: breaking API changes are more likely to be caught and fixed by the team that controls both sides.
  • Apache-2.0 license with no usage restrictions: Apache-2.0 is an OSI-approved permissive license. You can use, modify, and distribute the CLI commercially, embed it in proprietary tooling, and run it in internal company infrastructure without restriction. No copyleft clause, no additional terms beyond the Apache-2.0 grant.
  • Shebang support for single-file GPU scripts: Add `#!/usr/bin/env -S colab run --gpu L4 --keep` as the shebang line of a `.py` file, make it executable, and run it directly with `./train.py`. The CLI provisions the runtime, executes the script, and can keep the session alive for inspection. This makes GPU scripts as portable as local shell scripts.
  • Activity-based liveness without manual keepalive: Colab's backend automatically tracks kernel activity and maintains session liveness while the CLI is active. No keepalive polling, heartbeat requests, or watchdog scripts are needed in user code. The backend manages this automatically, matching standard Colab behavior in the browser.

Trade-offs

  • Linux and macOS only; Windows is not supported: The CLI currently runs on Linux and macOS. Windows users cannot install or run it. The README states this explicitly as a known platform limitation, with no announced timeline for Windows support.
  • Compute runs on Google's infrastructure, not self-hosted: The CLI is Apache-2.0 open source, but all actual computation happens on Google Colab's cloud hardware. You cannot run Colab GPU or TPU runtimes on your own servers. Access to GPUs and TPUs requires a Google account and may require a Colab Pro or Pro+ subscription for specific accelerators.
  • Released in April 2026 with 19 open issues: The repository was created in April 2026 and has 19 open issues. As a recently released tool with active development, some edge cases and integration scenarios may have bugs or undocumented limitations. The GitHub issue tracker is the most accurate source for known problems before integrating the CLI into production pipelines.

Tech stack

Languages
Python, Shell
Frameworks
—
Databases
—
Tooling
—

FAQ

Does Google Colab CLI work on Windows?

No. The README states explicitly that Windows is not supported. The CLI runs on Linux and macOS only, with no announced timeline for Windows support. Windows users will need to run it inside WSL2 or a Linux VM if they want to test it.

Do I need a Google Colab Pro subscription to use the CLI?

A Google account is required. The free Colab tier gives access to CPU runtimes and limited GPU availability. For reliable T4, L4, A100, or TPU runtimes, a Colab Pro or Pro+ subscription is needed, the same as with the web interface. The CLI does not change the runtime entitlements: it is a terminal interface to the same account.

Can I use the Colab CLI in automated CI/CD pipelines?

Yes, with the `--auth adc` flag for non-interactive authentication via Application Default Credentials. Run `gcloud auth application-default login` with the required Colab scopes first, as listed in the README's Global Options section. The `colab run` command is designed for ephemeral job execution: provision, run, retrieve output, and terminate in one command without any interactive steps.

How does the CLI authenticate with Google?

By default it uses OAuth2 (`--auth oauth2`), which requires a one-time interactive browser login. For automation, switch to Application Default Credentials with `--auth adc` and authenticate with `gcloud auth application-default login` using the required scopes listed in the README. Session tokens are stored at `~/.config/colab-cli/sessions.json`.

Can I keep the runtime alive after a script finishes?

Yes. The `--keep` flag on `colab run` tells the CLI to preserve the runtime after the script completes, so you can inspect logs, re-run code, or download additional files before stopping it manually with `colab stop`. Without `--keep`, the runtime is released automatically when the script exits.

Similar tools

More in Engineers