本周,Google AI 团队发布了 Colab CLI。该工具将你的本地终端连接到远程 Colab 运行时。它让开发者和 AI 智能体能够在云端 GPU 和 TPU 上运行代码。你全程都停留在自己的终端里。该 CLI 以 Apache 2.0 许可证开源。
什么是 Google Colab CLI
Colab CLI 是 Google Colab 的命令行界面。你可以在终端中创建会话、运行代码并管理文件。
任何具备终端访问权限的智能体都可以调用该工具。这包括 Claude Code、Codex 和 Google 的 Antigravity。Google 附带了一个名为 COLAB_SKILL.md 的预打包技能文件。它为智能体提供了关于如何使用该 CLI 的内置上下文。
安装只需从 GitHub 仓库执行一条 uv tool install 命令。
uv tool install git+https://github.com/googlecolab/google-colab-cli 一个最简会话如下所示:
colab new # provision a CPU session
echo "print('hello')" | colab exec # run code
colab stop # release the VM
命令如何工作
该 CLI 将命令分为会话、执行、文件和自动化几类。colab new 会创建一个会话,默认使用 CPU。添加 --gpu T4、--gpu L4、--gpu A100 或 --gpu H100 可使用 GPU。TPU 选项为 v5e1 和 v6e1。
colab exec 可从 stdin、.py 文件或 notebook 运行 Python。exec 在本地读取文件并传输其内容。因此本地编辑无需单独的上传步骤。colab stop 会终止会话并释放 VM。
其他命令涵盖文件和身份验证。colab upload 和 colab download 在本地和远程之间移动文件。colab drivemount 挂载 Google Drive,默认挂载 /content/drive。colab auth 为 VM 进行 Google Cloud 服务的身份验证。
colab exec 与产物恢复:核心循环
核心循环很短。你配置一个运行时,运行一个脚本,然后把结果拉回来。colab download 获取模型、数据集和其他文件。colab log 将会话历史导出为 .ipynb、.md、.txt 或 .jsonl。
因此一次远程运行就变成了你磁盘上一个可回放的 notebook。colab repl 和 colab console 提供对 VM 的交互式访问。colab install 通过 uv 添加软件包,回退到 pip。会话元数据存储在 ~/.config/colab-cli/sessions.json。
示例:微调 Gemma 3 1B
Google 的官方发布演示了一个由智能体驱动的微调任务。该任务使用 QLoRA 微调 google/gemma-3-1b-it。它在 Text-to-SQL 数据集上训练以改进 SQL 生成。Antigravity 智能体用五条命令运行整个流程。
colab new --gpu T4
colab install transformers datasets peft trl bitsandbytes accelerate
colab exec -f finetune_run.py
colab log --output gemma_finetune_log.ipynb
colab stop 随后,智能体会下载适配器模型、适配器配置、tokenizer 配置以及 tokenizer。你可以在本地加载并部署微调后的模型。用户无需手动输入任何云端资源配置命令。
使用场景
- 将原本局限于笔记本电脑的训练任务卸载到远程 GPU 或 TPU,无需离开终端。
- 让 Claude Code、Codex 或 Antigravity 等智能体运行端到端的机器学习流水线。
- 通过 QLoRA 远程微调小型模型,例如 Gemma 3 1B。
- 以脚本方式执行 notebook 并导出可回放的
.ipynb日志,以确保可复现性。 - 通过
colab repl或colab console在虚拟机上交互式调试。
Colab CLI 与基于浏览器的 Colab 对比
CLI 并不会取代 notebook UI。它面向的是脚本化、自动化以及智能体驱动的工作。以下是两种工作流在常见任务上的对比。
| 维度 | 基于浏览器的 Colab | Colab CLI |
|---|---|---|
| 界面 | Web 笔记本界面 | 本地终端 |
| 加速器选择 | 浏览器中的运行时菜单 | --gpu / --tpu 标志位于 colab new |
| 智能体使用 | 手动、界面驱动 | 通过命令使用任意终端智能体 |
| 运行本地脚本 | 粘贴或上传到单元格 | colab exec -f script.py |
| 产物检索 | 手动下载或 Drive | colab download、colab log |
| 安装包 | 在单元格内使用 !pip | colab install(先 uv,再 pip) |
| 会话控制 | 浏览器管理的运行时 | colab new、colab stop、colab status |
| 智能体技能文件 | 无 | 捆绑的 COLAB_SKILL.md |
优势与考量
优势:
- 终端原生工作流,适配脚本、CI 和智能体循环。
- 一条命令即可配置 T4、L4、A100 或 H100 GPU。
exec直接传输本地文件内容,因此无需上传步骤。- 日志可导出为可回放的 notebook 格式,以保证可复现性。
- 基于 Apache 2.0 开源,并附带一个捆绑的智能体技能文件。
- 可配合多种智能体使用,而非局限于单一厂商的工具。
考量:
- 访问需要身份验证;默认策略为
oauth2。 repl和console在交互式运行时需要 TTY。- 在脚本中通过管道传入 stdin 即可使用这两个命令。
- 计算仍然在 Colab 的后端及其运行时模型上运行。
核心要点
- Google 的 Colab CLI 让你可以从本地终端在远程 Colab GPU 和 TPU 上运行代码。
- 一条命令即可配置加速器:
colab new --gpu T4到A100以及H100,外加 TPU。 colab exec无需上传步骤,即可将本地.py和.ipynb文件传送到运行时。- 任何终端智能体——Claude Code、Codex、Antigravity——都可以通过内置的
COLAB_SKILL.md来驱动它。 - 它以 Apache 2.0 协议开源,并且
colab log可导出可回放的 notebook 日志。
Marktechpost 可视化解读
Google Colab CLI — 终端指南
从你的终端运行 Colab GPU 和 TPU
Google Colab CLI 将你的本地终端连接到远程 Colab 运行时。开发者和 AI 智能体无需离开 shell 即可在云端加速器上运行代码。
2026 年 6 月 5 日发布 • 基于 Apache 2.0 开源
它是什么
- 一个用于 Google Colab 的命令行界面。
- 它将你的本地终端连接到远程 Colab 运行时。
- 你可以在终端中创建会话、运行代码并管理文件。
- 任何基于终端的 AI 智能体也可以调用它。
安装与快速开始
用一条命令安装,然后运行第一个会话。
uv tool install git+https://github.com/googlecolab/google-colab-cli
colab new # provision a CPU session
echo "print('hello')" | colab exec # run code
colab stop # release the VM 配置 GPU 和 TPU
在创建会话时申请加速器。默认使用 CPU。
colab new --gpu T4
colab new --gpu A100
colab new --tpu v6e1 加速器的可用性取决于你当前生效的 Colab 套餐。
远程运行本地脚本
exec 命令会在本地读取你的文件并传输其内容。无需单独的上传步骤。
colab exec -f train.py exec 可从 stdin、.py 文件或 notebook 运行 Python。
检索模型和日志
运行结束后将结果拉回你的机器。
colab download -s NAME checkpoints/model.bin ./model.bin
colab log -o report.ipynb 日志可导出为 .ipynb、.md、.txt 或 .jsonl。
示例:微调 Gemma 3 1B
Google 的博客展示了一个智能体在 Text-to-SQL 数据集上运行 QLoRA 流水线。
colab new --gpu T4
colab install transformers datasets peft trl bitsandbytes accelerate
colab exec -f finetune_run.py
colab log --output gemma_finetune_log.ipynb
colab stop 为 AI 智能体而构建
- 任何具备终端访问权限的智能体都可以调用该 CLI。
- 它可与 Claude Code、Codex 和 Antigravity 配合使用。
- 随附的 COLAB_SKILL.md 为智能体提供内置上下文。
- 结果是:可脚本化、面向智能体的 Colab 算力。
This week, Google AI team released the Colab CLI. The tool connects your local terminal to remote Colab runtimes. It lets developers and AI agents run code on cloud GPUs and TPUs. You stay in your terminal the entire time. The CLI is open source under the Apache 2.0 license.
What is Google Colab CLI
The Colab CLI is a command-line interface for Google Colab. You can create sessions, run code, and manage files from the terminal.
Any agent with terminal access can call the tool. That includes Claude Code, Codex, and Google’s Antigravity. Google ships a prepackaged skill file named COLAB_SKILL.md. It gives agents built-in context on how to use the CLI.
Installation uses a single uv tool install command from the GitHub repository.
uv tool install git+https://github.com/googlecolab/google-colab-cli A minimal session looks like this:
colab new # provision a CPU session
echo "print('hello')" | colab exec # run code
colab stop # release the VM
How the Commands Work
The CLI groups commands into sessions, execution, files, and automation. colab new provisions a session, with CPU as the default. Add --gpu T4, --gpu L4, --gpu A100, or --gpu H100 for a GPU. TPU options are v5e1 and v6e1.
colab exec runs Python from stdin, a .py file, or a notebook. The exec reads files locally and ships their contents. Local edits therefore need no separate upload step. colab stop terminates the session and releases the VM.
Other commands cover files and authentication. colab upload and colab download move files between local and remote. colab drivemount mounts Google Drive, defaulting to /content/drive. colab auth authenticates the VM for Google Cloud services.
colab exec and Artifact Recovery: The Core Loop
The core loop is short. You provision a runtime, run a script, then pull results back. colab download retrieves models, datasets, and other files. colab log exports session history as .ipynb, .md, .txt, or .jsonl.
So a remote run becomes a replayable notebook on your disk. colab repl and colab console give interactive access to the VM. colab install adds packages with uv, falling back to pip. Session metadata is stored at ~/.config/colab-cli/sessions.json.
Example: Fine-Tuning Gemma 3 1B
Google’s official release demonstrates an agent-driven fine-tuning job. The task fine-tunes google/gemma-3-1b-it using QLoRA. It trains on a Text-to-SQL dataset to improve SQL generation. The Antigravity agent runs the full pipeline with five commands.
colab new --gpu T4
colab install transformers datasets peft trl bitsandbytes accelerate
colab exec -f finetune_run.py
colab log --output gemma_finetune_log.ipynb
colab stop The agent then downloads the adapter model, adapter config, tokenizer config, and tokenizer. You can load and serve the fine-tuned model locally. No manual cloud provisioning command was typed by the user.
Use Cases
- Offload laptop-bound training to a remote GPU or TPU without leaving the terminal.
- Let agents like Claude Code, Codex, or Antigravity run end-to-end ML pipelines.
- Fine-tune small models, such as Gemma 3 1B, with QLoRA remotely.
- Script notebook execution and export replayable
.ipynblogs for reproducibility. - Debug interactively on the VM through
colab replorcolab console.
Colab CLI vs Browser-Based Colab
The CLI does not replace the notebook UI. It targets scripted, automated, and agent-driven work instead. Here is how the two workflows compare across common tasks.
| Dimension | Browser-Based Colab | Colab CLI |
|---|---|---|
| Interface | Web notebook UI | Local terminal |
| Accelerator selection | Runtime menu in the browser | --gpu / --tpu flags on colab new |
| Agent use | Manual, UI-driven | Any terminal agent via commands |
| Run local scripts | Paste or upload into cells | colab exec -f script.py |
| Artifact retrieval | Manual download or Drive | colab download, colab log |
| Package install | !pip inside a cell | colab install (uv, then pip) |
| Session control | Browser-managed runtime | colab new, colab stop, colab status |
| Agent skill file | None | Bundled COLAB_SKILL.md |
Strengths and Considerations
Strengths:
- Terminal-native workflow fits scripts, CI, and agent loops.
- One command provisions T4, L4, A100, or H100 GPUs.
execships local file contents, so no upload step is needed.- Logs export to replayable notebook formats for reproducibility.
- Open source under Apache 2.0, with a bundled agent skill file.
- Works with multiple agents, not a single vendor’s tool.
Considerations:
- Access requires authentication; the default strategy is
oauth2. replandconsoleneed a TTY when run interactively.- Pipe stdin to use those two commands inside scripts.
- Compute still runs on Colab’s backend and its runtime model.
Key Takeaways
- Google’s Colab CLI runs code on remote Colab GPUs and TPUs from your local terminal.
- One command provisions accelerators:
colab new --gpu T4throughA100andH100, plus TPUs. colab execships local.pyand.ipynbfiles to the runtime without an upload step.- Any terminal agent — Claude Code, Codex, Antigravity — can drive it via a bundled
COLAB_SKILL.md. - It is open source under Apache 2.0, and
colab logexports replayable notebook logs.
Marktechpost Visual Explainer
Google Colab CLI — Terminal Guide
Run Colab GPUs and TPUs from your terminal
The Google Colab CLI connects your local terminal to remote Colab runtimes. Developers and AI agents run code on cloud accelerators without leaving the shell.
Announced June 5, 2026 • Open source under Apache 2.0
What it is
- A command-line interface for Google Colab.
- It connects your local terminal to remote Colab runtimes.
- You create sessions, run code, and manage files from the terminal.
- Any terminal-based AI agent can call it too.
Install and quick start
Install with a single command, then run a first session.
uv tool install git+https://github.com/googlecolab/google-colab-cli
colab new # provision a CPU session
echo "print('hello')" | colab exec # run code
colab stop # release the VM Provision GPUs and TPUs
Request an accelerator when you create the session. CPU is the default.
colab new --gpu T4
colab new --gpu A100
colab new --tpu v6e1 Accelerator availability depends on your active Colab plan.
Run local scripts remotely
The exec command reads your file locally and ships its contents. No separate upload step is needed.
colab exec -f train.py exec runs Python from stdin, a .py file, or a notebook.
Retrieve models and logs
Pull results back to your machine after the run.
colab download -s NAME checkpoints/model.bin ./model.bin
colab log -o report.ipynb Logs export as .ipynb, .md, .txt, or .jsonl.
Example: fine-tune Gemma 3 1B
Google’s blog shows an agent running a QLoRA pipeline on a Text-to-SQL dataset.
colab new --gpu T4
colab install transformers datasets peft trl bitsandbytes accelerate
colab exec -f finetune_run.py
colab log --output gemma_finetune_log.ipynb
colab stop Built for AI agents
- Any agent with terminal access can call the CLI.
- It works with Claude Code, Codex, and Antigravity.
- A bundled COLAB_SKILL.md gives agents built-in context.
- The result: scriptable, agent-ready Colab compute.