colab-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseColab CLI
Colab CLI
Use the command to run local Python work on remote Google Colab runtimes.
Prefer this skill when the user wants Colab compute, GPUs, TPUs, notebook logs,
remote execution, or agent-driven ML jobs.
colab使用 命令在远程 Google Colab runtime 上运行本地 Python 任务。
当用户需要 Colab 算力、GPU、TPU、notebook 日志、
远程执行或 Agent 驱动的 ML 任务时,优先使用此 skill。
colabInstall And Verify
安装与验证
Check the local tool first:
bash
colab version
colab --helpIf missing, install it with :
uvbash
uv tool install google-colab-cli先检查本地工具:
bash
colab version
colab --help如果尚未安装,请使用 进行安装:
uvbash
uv tool install google-colab-cliCurrent release and remaining hardening caveats
当前版本与尚存的加固注意事项
Guidance was revalidated on 2026-10-01 against upstream and the user fork branch . That branch is based on current upstream and adds the remaining hardening plus persistent DriveFS. If succeeds, prefer the fork workflow below and do not apply stock-only caveats as if they were unfixed.
mainall-fixes/persistent-drive-2026-10-01a84e094colab drive-mount --helpUpgrade old 0.7.2 installs before troubleshooting their known dependency and
runtime-token failures:
bash
colab update --install
colab versionVersion 0.7.4 fixes the 0.7.2 execution breakage
and adds automatic runtime-proxy token refresh. Do not keep the old
workaround or the old "~1 hour proxy token
expiry" recovery procedure once 0.7.4+ is installed.
jupyter-kernel-client==0.8jupyter-kernel-client>=0.9,<1Current upstream also pins ; the v0.7.4 tag
still declared . If an exact 0.7.4 environment resolves an older
WebSocket client and loses the server's HTTP 400 reason, upgrade
that dependency inside the same environment as the executable:
mainwebsocket-client>=1.6>=1.0colab sshcolabbash
uv pip install --python ~/.local/share/uv/tools/google-colab-cli/bin/python \
"websocket-client>=1.6"Several local-security and reliability findings remain in current upstream.
Treat , , , and
as sensitive and never publish them unredacted. On
multi-user machines, restrict them to the current user:
~/.config/colab-cli/token.jsonsessions.jsoncolab.loghistory/*.jsonlbash
chmod 700 ~/.config/colab-cli ~/.config/colab-cli/history 2>/dev/null || true
chmod 600 ~/.config/colab-cli/{token.json,sessions.json,colab.log,settings.json} 2>/dev/null || true
chmod 600 ~/.config/colab-cli/history/*.jsonl 2>/dev/null || trueDo not use for secrets on stock upstream: environment values can be
embedded in executed Python/history. Interactive stdin replies are also stored
in history. Use proper remote secret-loading mechanisms and review history
before sharing it.
--envThe CLI bundles and , but version-sensitive
behavior should be verified against the installed binary and exact source.
remains the parser default in v0.7.4/current main.
colab skillcolab readmeoauth2本指南于 2026-10-01 基于上游 和用户 fork 分支 重新验证。该分支基于当前上游 ,补充了其余加固措施及持久化 DriveFS。如果 成功,请优先采用下述 fork 工作流,不要把仅适用于原版上游的注意事项当作尚未修复的问题来套用。
mainall-fixes/persistent-drive-2026-10-01a84e094colab drive-mount --help在排查旧版 0.7.2 安装的已知依赖和 runtime-token 故障之前,请先升级:
bash
colab update --install
colab version0.7.4 版本修复了 0.7.2 中 导致的执行中断,并增加了 runtime proxy token 自动刷新。安装 0.7.4+ 后,不要再使用旧的 变通方案,也不要继续沿用旧的“约 1 小时 proxy token 过期”恢复流程。
jupyter-kernel-client==0.8jupyter-kernel-client>=0.9,<1当前上游 还会锁定 ;v0.7.4 tag 仍声明为 。如果精确使用 0.7.4 的环境解析到了较旧的 WebSocket client,且 丢失服务器的 HTTP 400 reason,请在 可执行文件所在的同一环境中升级该依赖:
mainwebsocket-client>=1.6>=1.0colab sshcolabbash
uv pip install --python ~/.local/share/uv/tools/google-colab-cli/bin/python \
"websocket-client>=1.6"当前上游仍存在若干本地安全性和可靠性问题。请将 、、 和 视为敏感文件,绝不要未经脱敏就发布它们。在多用户机器上,应将其权限限制为仅当前用户可访问:
~/.config/colab-cli/token.jsonsessions.jsoncolab.loghistory/*.jsonlbash
chmod 700 ~/.config/colab-cli ~/.config/colab-cli/history 2>/dev/null || true
chmod 600 ~/.config/colab-cli/{token.json,sessions.json,colab.log,settings.json} 2>/dev/null || true
chmod 600 ~/.config/colab-cli/history/*.jsonl 2>/dev/null || true在原版上游中,不要使用 传递 secret:环境变量值可能会嵌入已执行 Python 或 history 中。交互式 stdin 回复也会存储在 history 中。请使用恰当的远程 secret 加载机制,并在共享 history 前进行检查。
--envCLI 内置了 和 ,但对版本敏感的行为应根据已安装的 binary 和确切源码进行验证。在 v0.7.4 和当前 main 中, 仍是 parser 默认值。
colab skillcolab readmeoauth2Mental Model
心智模型
- A session is a live Jupyter kernel on a rented Colab VM. allocates compute;
colab newreleases it.colab stop - Kernel state persists across and piped
colab execcalls in the same session. Imports, variables, and functions remain untilcolab replorcolab restart-kernel.colab stop - Execution starts in . Prefer absolute
/contentpaths for remote files so later/content/...,ls, and cleanup commands are unambiguous.download - Commands that access the Colab control plane authenticate on demand, perform
their operation, and exit. Pure informational commands such as ,
version, andhelpdo not need control-plane authentication. Current upstream runs no client-side keep-alive daemon; backend liveness depends on kernel activity and Colab policy.readme
- session 是租用 Colab VM 上正在运行的 Jupyter kernel。分配算力;
colab new释放算力。colab stop - 在同一个 session 中,kernel 状态会在 和通过管道输入的
colab exec调用之间持续保留。import、变量和函数会一直存在,直到执行colab repl或colab restart-kernel。colab stop - 执行工作目录从 开始。远程文件优先使用绝对路径
/content,以确保后续/content/...、ls和清理命令的路径明确无歧义。download - 访问 Colab control plane 的命令会按需进行身份验证、执行相应操作后退出。、
version和help等纯信息命令不需要 control plane 身份验证。当前上游不会在客户端运行 keep-alive daemon;后端存活性取决于 kernel 活跃度和 Colab 策略。readme
Agent Rules
Agent 规则
- Always make a lifecycle plan before allocating compute: session name, hardware, commands to run, artifacts to retrieve, and cleanup command.
- Use an explicit session name with for
-s <name>, multi-step sessions, andcolab new. Plain one-shotcolab run --keepmay safely use its generated ephemeral name because it tears the runtime down itself.colab run - Prefer for one-shot jobs because it provisions, executes, and stops the runtime automatically.
colab run - Use a named session for multi-step work: , then
colab new -s <name>,colab install,colab exec,colab download,colab log.colab stop - does not attach to an existing session:
colab run -s <name>only labels the fresh ephemeral VM that-sprovisions and releases. To execute code on an existing session, userun.colab exec -s <name> - Do not leave paid resources running. Run when done, then verify with
colab stop -s <name>.colab sessions - Never start unpiped or
colab replfrom a non-interactive agent shell. They are TTY-oriented. Usecolab console,colab exec, or pipe stdin into the interactive command.colab run - Treat unpiped , unpiped
colab repl,colab console, and stock interactivecolab authas user-interactive. On the unified fork,colab drivemountneeds the user once; subsequentcolab drive-mount loginandcolab drive-mount -s NAMEare agent-runnable when persistent credentials are configured.colab drivemount -s NAME - Do not edit by hand. Use CLI commands. A missing local name does not prove its VM stopped: before reallocating after
~/.config/colab-cli/sessions.json, reconcile server-side assignments withSession not found; an orphan can remain allocated and billable.colab sessions - Do not upgrade/reinstall/switch Colab CLI or change Drive transport underneath a valuable live job. Prefer checkpoint -> collect -> stop/verify -> upgrade -> new session. If unavoidable, preserve a private name-to-endpoint recovery record first. See .
references/session-resilience-2026-10-01.md - For live probes, remember that and
colab newcan allocate real compute units. Clean up even after failed jobs.colab run - For parallel agents or risky probes, isolate session state with
.
--config /tmp/<name>.json
- 分配算力前,务必制定生命周期计划:session 名称、硬件、要运行的命令、要取回的产物以及清理命令。
- 对于 、多步骤 session 和
colab new,使用colab run --keep指定明确的 session 名称。普通的一次性-s <name>可以安全使用自动生成的临时名称,因为它会自行释放 runtime。colab run - 对于一次性任务,优先使用 ,因为它会自动配置、执行并停止 runtime。
colab run - 多步骤工作使用命名 session:,然后依次使用
colab new -s <name>、colab install、colab exec、colab download、colab log。colab stop - 不会附加到已有 session:
colab run -s <name>只会为-s创建并释放的临时 VM 命名。要在已有 session 上执行代码,请使用run。colab exec -s <name> - 不要让付费资源持续运行。完成工作后运行 ,再通过
colab stop -s <name>进行验证。colab sessions - 在非交互式 Agent shell 中,绝不要启动未通过管道提供 stdin 的 或
colab repl。它们面向 TTY。请使用colab console、colab exec,或通过管道将 stdin 输入交互式命令。colab run - 将未通过管道提供 stdin 的 、
colab repl、colab console和原版上游的交互式colab auth视为用户交互操作。在统一 fork 上,colab drivemount需要用户操作一次;配置好持久化凭据后,后续的colab drive-mount login和colab drive-mount -s NAME可由 Agent 运行。colab drivemount -s NAME - 不要手动编辑 。应使用 CLI 命令。本地缺少某个名称并不能证明其 VM 已停止:遇到
~/.config/colab-cli/sessions.json后,在重新分配资源之前,先使用Session not found核对服务器端分配记录;孤立 session 可能仍占用资源并产生费用。colab sessions - 不要在 valuable 活跃任务运行期间升级、重新安装或切换 Colab CLI,也不要在任务下方更改 Drive transport。优先执行 checkpoint -> collect -> stop/verify -> upgrade -> new session。如果无法避免,请先保存一份私密的 session 名称到 endpoint 映射恢复记录。参见 。
references/session-resilience-2026-10-01.md - 进行实际探测时,请记住 和
colab new可能会分配真实的算力单元。即使任务失败,也要执行清理。colab run - 对于并行 Agent 或高风险探测,使用 隔离 session 状态。
--config /tmp/<name>.json
Runtime Cost And Duration Best Practices
Runtime 成本与时长最佳实践
- Treat every allocated Colab session as potentially credit-consuming until it is explicitly stopped.
- End every persistent-session workflow with , then run
colab stop -s <name>to confirm there are no leftover active sessions. Plaincolab sessionsstops its own runtime unlesscolab runis set.--keep - Prefer for one-shot work because it stops the runtime automatically unless
colab runis set.--keep - Avoid unless the user needs post-run inspection. If
--keepis used, report the session name and stop it as soon as inspection is finished.--keep - Colab runtime availability, maximum lifetime, idle timeout, accelerator access, and compute-unit consumption vary by account, subscription tier, current demand, and hardware choice. Do not promise a fixed runtime duration.
- For long jobs, write checkpoints and logs to retrievable paths such as
or Google Drive, and download/export artifacts before cleanup.
/content/outputs - For current compute-unit consumption, run : it reads
colab usageand prints current balance, hourly usage rate, and active assignment count. Treat the numbers as point-in-time account data, not a guaranteed rate table; availability, maximum lifetime, idle timeout, and accelerator access still vary by tier, demand, and hardware. Do not hardcode old web/forum CU/hour tables as truth. A dated measured snapshot lives atGET /tun/m/ccu-info(rates + provisioned hardware per backend, account/region-specific).references/cu-rate-card-2026-09-24.md - When the account runs out of compute units, opens the Colab subscription page to top up. It launches a browser, so treat it as user-interactive and suggest it rather than running it blindly.
colab pay - is accepted by
--high-mem,colab new, andcolab runwhen SSH creates a runtime:colab ssh. Current upstream sendscolab new -s trainer --gpu A100 --high-memfor CPU, T4, G4, H100, and A100, while L4 and TPU (shape=hm,v5e1) omit the shape and print an ignored-flag warning because they are treated as single-shape accelerators. The binary help says high-RAM requests require "Colab Pro or Pro+ entitlement"; actual backend entitlement and availability remain account-dependent. Verify assigned shape withv6e1. Current upstreamcolab sessionsstill renders the locally cached requested shape rather than preferring backendcolab status -s <name>; the fork hardening branch fixes this.machineShape
- 将每个已分配的 Colab session 视为可能消耗算力额度的资源,直至明确停止它。
- 每个持久 session 工作流都以 结束,然后运行
colab stop -s <name>,确认没有遗留的活跃 session。除非设置了colab sessions,普通--keep会自动停止自己的 runtime。colab run - 对于一次性任务,优先使用 ,因为除非设置
colab run,它会自动停止 runtime。--keep - 除非用户需要检查运行结果,否则避免使用 。如果使用了
--keep,请报告 session 名称,并在检查完成后立即停止它。--keep - Colab runtime 的可用性、最长存活时间、空闲超时、accelerator 访问权限和 compute unit 消耗会因账户、订阅层级、当前需求和硬件选择而异。不要承诺固定的 runtime 时长。
- 对于长时间任务,请将 checkpoint 和日志写入 或 Google Drive 等可取回路径,并在清理前下载或导出产物。
/content/outputs - 如需查看当前 compute unit 消耗情况,运行 :它会读取
colab usage并打印当前余额、每小时使用率和活跃分配数量。请将这些数字视为某一时间点的账户数据,而不是有保证的费率表;可用性、最长存活时间、空闲超时以及 accelerator 访问权限仍会随套餐层级、需求和硬件而变化。不要将旧网站或论坛中的 CU/hour 表当作事实依据。按日期记录的实测快照位于GET /tun/m/ccu-info(费率 + 各后端已配置的硬件,因账户或地区而异)。references/cu-rate-card-2026-09-24.md - 当账户的 compute unit 用尽时,会打开 Colab 订阅页面进行充值。它会启动浏览器,因此应将其视为用户交互操作;建议用户执行,不要盲目运行。
colab pay - 、
colab new和colab run均支持colab ssh(当 SSH 创建 runtime 时):--high-mem。当前上游会为 CPU、T4、G4、H100 和 A100 发送colab new -s trainer --gpu A100 --high-mem,而 L4 和 TPU(shape=hm、v5e1)不会发送该 shape,并打印“已忽略该标志”的警告,因为它们被视为单 shape accelerator。binary help 指出,高 RAM 请求需要“Colab Pro 或 Pro+ entitlement”;实际的后端 entitlement 和可用性仍取决于账户。请使用v6e1验证分配的 shape。当前上游的colab sessions仍会呈现本地缓存的请求 shape,而不会优先采用后端colab status -s <name>;fork 加固分支修复了这一点。machineShape
Long-Running Unattended Jobs (Agent Best Practice)
长时间无人值守任务(Agent 最佳实践)
Field lessons from multi-hour, multi-session GPU benchmark campaigns. Each rule
exists because skipping it cost a session setup or a silent stall.
- Smoke before the long run, in the same session. Make the job script run
a tiny end-to-end pass first (one input, one repeat, every output-writing
step, including result packaging) and exit non-zero before the long part if
it fails. Setup (venv, model download) is shared, so the check is nearly
free. and local unit tests do not catch runtime-only failures.
bash -n - Smoke every mode, not a sample. If the long part runs a tool in several
modes or with extra flags (then
fuzz,pipeline), each one needs its own smoke twin with the same subcommand and flags; only size flags (cases, repeats, limit, output paths) may differ. A mode that was never smoked can still hit a gate or import path the smoked one skips. Enforce it mechanically (a small lint over job scripts run in CI and before launch) rather than by memory; context resets and compaction forget checklists.--evaluate-x - Admit each paid job against the whole plan. Before every allocation, read
fresh and start the job only if balance minus account floor, safety guard, and the caps still reserved for later mandatory jobs covers this job's cap. A per-job cap alone lets early jobs eat budget later gates need.
colab usage - Ship an exact code snapshot and pin the runtime. Upload one (not a working-tree tar), clone it remotely, and log the commit; record
git bundleat job start and compare it when collecting, so outputs from a restarted or replaced VM (empty/proc/sys/kernel/random/boot_id, stale markers) are detected instead of trusted./content - Assume nothing about the image. Probe tools you call () in the smoke step. Colab has no GNU
command -v; time with bash/usr/bin/timeor Python. Application safety guards (for example a "refusing full run without approval" flag) also fire at runtime: pass the intended subset flag explicitly, never disable the guard.$SECONDS - Detach, mark completion, poll the marker. Launch with from a tiny
setsid nohup bash job.shscript, redirect all output to a log file, and write the exit code withcolab exec. Poll fortrap 'echo "exit=$?" > $OUT/done' EXITat most once a minute; never hold a$OUT/doneopen for the job's whole duration.colab exec - Bound every poll. A call can hang for tens of minutes. Wrap pollers in
colab exec(or kill the stuck call by PID) so one hung call cannot stall collection of the other sessions.timeout 120 colab exec ... - Collect, verify, then stop. When the marker appears, tar the output
directory remotely (exclude large media), download one archive, check it
exists locally, then immediately so no GPU idles.
colab stop - Upload size. Large single uploads fail with (seen at about 120 MB). Split into parts of about 40 MB (
400 Bad Request), upload them, andsplit -b 40Mthem back together inside the job before verifying hashes.cat - Concurrency. GPU allocations beyond the account's concurrent limit fail
with (three G4 sessions were the limit in one account; CPU runtimes did not count). Queue the extra job and backfill it when a collector frees a slot, instead of retrying in a loop.
Allocation refused (precondition failed) - Parallel only where it is valid. Independent correctness runs can use separate sessions of the same accelerator type; A/B timing belongs in one session with interleaved arms, because separate VMs add hardware noise.
- Hermetic Python on Colab. Preinstalled local-version wheels (for example
) break
torchaudio 2.11.0+cu128installs and leftover packages (for example--require-hashes) break imports; install locked dependencies into a freshtorchvision. The kernel exportsuv venv, which a fresh venv lacks: setMPLBACKEND=module://matplotlib_inline....MPLBACKEND=Agglooks like a proxy to urllib (NLTK 3.10 refuses downloads): unset it for that one command instead of disabling the library's guard.COLAB_LANGUAGE_SERVER_PROXY - Kill by PID, not pattern, locally. can match the agent's own shell command line and kill it.
pkill -f <pattern>
以下经验来自多小时、多 session 的 GPU benchmark campaign。跳过其中任何规则都曾导致 session 设置失败或静默停滞。
- 在长任务之前,于同一 session 中进行 smoke test。 让 job script 先运行一个微型端到端测试(一个输入、一次重复、每个输出写入步骤,包括结果打包),如果失败则在长任务部分开始前以非零状态退出。环境准备(venv、模型下载)可以共享,因此该检查几乎不产生额外成本。和本地 unit test 无法发现仅在 runtime 中出现的故障。
bash -n - 测试每种模式,而不只是抽样。 如果长任务部分会以多种模式或额外 flags(后运行
fuzz、pipeline)运行某个工具,每种模式都需要一个使用相同子命令和 flags 的 smoke twin;只有大小相关参数(cases、repeats、limit、output paths)可以不同。未经过 smoke 的模式仍可能触发已 smoke 模式会跳过的 gate 或 import 路径。应通过机制强制执行(在 CI 中以及启动前,对 job scripts 运行一个小型 lint),而不是依靠记忆;context 重置和压缩会让人忘记 checklist。--evaluate-x - 根据整个计划判断是否接纳每个付费任务。 在每次分配资源前,读取最新的 ,仅当余额扣除账户余额下限(floor)、安全 guard 以及为后续必需任务预留的 cap 后,仍能覆盖本任务的 cap,才启动任务。仅设置每个任务的 cap 会让早期任务消耗掉后续 gate 所需的预算。
colab usage - 提供精确的代码快照并固定 runtime。 上传一个 (不要使用 working-tree tar),在远端 clone,并记录 commit;在任务开始时记录
git bundle并在收集结果时比较,以便检测输出是否来自已重启或被替换的 VM(/proc/sys/kernel/random/boot_id为空、标记过期),而不是盲目信任结果。/content - 不要对镜像做任何假设。 在 smoke 步骤中探测你要调用的工具()。Colab 没有 GNU
command -v;请使用 bash/usr/bin/time或 Python 计时。应用安全 guard(例如“refusing full run without approval” flag)也会在 runtime 中触发:请显式传入目标子集 flag,绝不要禁用该 guard。$SECONDS - 分离进程、标记完成并轮询标记。 通过一个很小的 script 使用
colab exec启动任务,将所有输出重定向到日志文件,并通过setsid nohup bash job.sh写入 exit code。最多每分钟轮询一次trap 'echo "exit=$?" > $OUT/done' EXIT;切勿在整个任务期间一直保持$OUT/done打开。colab exec - 为每次轮询设置时限。 调用可能会挂起数十分钟。使用
colab exec包裹轮询器(或按 PID 终止卡住的调用),避免一次挂起阻塞其他 session 的结果收集。timeout 120 colab exec ... - 收集、验证,然后停止。 标记出现后,在远端 tar 输出目录(排除大型媒体),下载单个 archive,在本地确认其存在,然后立即执行 ,避免 GPU 空闲计费。
colab stop - 注意上传大小。 大型单次上传会失败并返回 (曾在约 120 MB 时出现)。请使用
400 Bad Request将其拆分为约 40 MB 的分片,分别上传,并在任务内部使用split -b 40M将其合并,然后验证 hash。cat - 并发。 超出账户并发限制的 GPU 分配会失败,并返回 (一个账户的 limit 是三个 G4 session;CPU runtime 不计入)。应将额外任务排队,并在 collector 释放 slot 后回填,而不是循环重试。
Allocation refused (precondition failed) - 仅在并行有效时使用并行。 相互独立的正确性运行可以使用相同 accelerator 类型的独立 session;A/B timing 应在同一 session 中交错执行,因为不同 VM 会引入硬件噪声。
- Colab 上的 Hermetic Python。 预装的本地版本 wheel(例如 )会破坏
torchaudio 2.11.0+cu128安装,残留软件包(例如--require-hashes)会破坏 import;请将锁定的依赖安装到全新的torchvision中。kernel 会导出uv venv,而全新 venv 缺少该设置:请设置MPLBACKEND=module://matplotlib_inline...。MPLBACKEND=Agg看起来像指向 urllib 的 proxy(NLTK 3.10 会拒绝下载):仅为该命令取消设置它,而不要禁用库的 guard。COLAB_LANGUAGE_SERVER_PROXY - 在本地按 PID 终止进程,不要按 pattern 终止。 可能匹配 Agent 自身的 shell 命令行并将其杀死。
pkill -f <pattern>
Backend Inventory And Benchmarking
后端资源清单与基准测试
The installed CLI advertises these accelerator selectors:
- CPU: omit and
--gpu--tpu - GPU: ,
--gpu T4,--gpu L4,--gpu G4,--gpu H100--gpu A100 - TPU: ,
--tpu v5e1--tpu v6e1
Observed Colab web UI behavior on 2026-06-06: high-memory toggles were available
for CPU-only, T4, and A100; L4 and TPU runtimes appeared to use their fixed
higher-memory shapes. Treat this as a snapshot, not a contract.
Availability is account-, region-, demand-, and subscription-dependent. A
supported selector can still return or fall back in the
web UI. Always inspect the actual assigned hardware with , CPU/RAM
checks, and task-specific benchmarks.
Service Unavailablenvidia-smiStock upstream does not validate accelerator selector strings strictly: an unrecognized value silently maps to A100 and an unrecognized value to v6e1. The unified fork rejects invalid selectors and simultaneous + before allocation. In either case, spell selectors exactly: GPU , , , , ; TPU , .
--gpu--tpu--gpu--tpuT4L4G4H100A100v5e1v6e1For a compact VPS-style profile, run the bundled benchmark script:
bash
colab run --session bench-cpu --timeout 600 \
colab-cli/scripts/benchmark-runtime.py cpu > cpu.json
colab run --session bench-t4 --gpu T4 --timeout 600 \
colab-cli/scripts/benchmark-runtime.py T4 > T4.jsonThe script records CPU model/core count, system RAM, disk size, disk read/write,
NumPy RAM-copy speed, GPU/TPU indicators, approximate FP32/FP16/BF16 matmul
throughput where supported, output, and cleanup-safe JSON. Read
the dated Pro+ snapshot in only as
an example of what one account received at one point in time.
speedtest-clireferences/pro-plus-snapshot-2026-06-06.mdFor scarce GPUs, do not conclude unavailability from one failed allocation. Use
the repo-level retry helper when the user explicitly wants persistence:
bash
ATTEMPTS=80 SLEEP_SECONDS=20 scripts/retry-gpu-benchmarks.sh G4 A100 H100This retries named sessions, validates JSON output, and checks
sessions between attempts. It can consume compute units when allocation
succeeds, so use it only with user approval.
colab runIf the user interrupts a retry or benchmark run, immediately check for local
wrapper and processes, stop the current named session if one exists,
and run :
colab runcolab sessionsbash
pgrep -a -f 'retry-gpu-benchmarks|colab run --session'
colab stop -s <current-session-name>
colab sessionsAn interrupted shell does not prove the remote assignment was released.
已安装的 CLI 声明支持以下 accelerator selector:
- CPU:省略 和
--gpu--tpu - GPU:、
--gpu T4、--gpu L4、--gpu G4、--gpu H100--gpu A100 - TPU:、
--tpu v5e1--tpu v6e1
2026-06-06 观察到的 Colab Web UI 行为:high-memory 开关可用于 CPU-only、T4 和 A100;L4 和 TPU runtime 似乎使用固定的高内存 shape。请将此视为快照,而非契约。
可用性取决于账户、地区、需求和订阅。即使 selector 受支持,仍可能返回 ,或在 Web UI 中回退到其他配置。请始终使用 、CPU/RAM 检查和特定任务的 benchmark 检查实际分配的硬件。
Service Unavailablenvidia-smi原版上游不会严格验证 accelerator selector 字符串:无法识别的 值会静默映射到 A100,无法识别的 值会静默映射到 v6e1。统一 fork 会在分配前拒绝无效 selector 以及同时使用 和 。无论如何,请准确拼写 selector:GPU 使用 、、、、;TPU 使用 、。
--gpu--tpu--gpu--tpuT4L4G4H100A100v5e1v6e1如需精简的 VPS 风格性能画像,请运行内置 benchmark script:
bash
colab run --session bench-cpu --timeout 600 \
colab-cli/scripts/benchmark-runtime.py cpu > cpu.json
colab run --session bench-t4 --gpu T4 --timeout 600 \
colab-cli/scripts/benchmark-runtime.py T4 > T4.json该脚本会记录 CPU 型号和核心数、系统 RAM、磁盘大小、磁盘读写速度、NumPy RAM-copy 速度、GPU/TPU 指标、受支持时的大致 FP32/FP16/BF16 matmul 吞吐量、 输出,以及 cleanup-safe JSON。仅将 中的 Pro+ 日期快照视为一个账户在某一时点所获配置的一个示例。
speedtest-clireferences/pro-plus-snapshot-2026-06-06.md对于稀缺 GPU,不要因一次分配失败就断定不可用。当用户明确希望持续尝试时,请使用 repo-level retry helper:
bash
ATTEMPTS=80 SLEEP_SECONDS=20 scripts/retry-gpu-benchmarks.sh G4 A100 H100它会重试命名的 session、验证 JSON 输出,并在各次尝试之间检查 session。分配成功时会消耗 compute unit,因此仅在用户批准后使用。
colab run如果用户中断 retry 或 benchmark run,请立即检查本地 wrapper 和 进程;如果存在当前命名 session,请将其停止,并运行 :
colab runcolab sessionsbash
pgrep -a -f 'retry-gpu-benchmarks|colab run --session'
colab stop -s <current-session-name>
colab sessions中断 shell 并不能证明远端分配已释放。
Authentication
身份验证
The global option chooses how the CLI authenticates to the Colab control
plane:
--authbash
colab --auth oauth2 sessions
colab --auth adc sessionsoauth2~/.colab-cli-oauth-config.json-c PATHOn stock upstream, issue #116 remains a granular-consent bug: a partial grant can break initial login or later refresh. The unified fork fixes this by persisting granted scopes, restoring them without re-expanding the request, relaxing only the token exchange, and requiring only control-plane scopes.
adcbash
gcloud auth application-default login --scopes=openid,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/colaboratoryDo not confuse CLI control-plane auth with . The
subcommand pushes credentials into the remote VM for notebook code that needs
GCP services such as BigQuery or Cloud Storage.
colab authcolab authDebug control-plane identity and scopes with:
bash
colab whoami
colab --auth adc whoamiauthwhoamicolab --helpwhoamiauthFor control-plane 401/403 errors, first run and inspect the
active provider and scopes. Current session allocation uses
; do not use obsolete
keep-alive troubleshooting.
colab whoamicolab.research.google.comcolab.pa.googleapis.com全局 选项决定 CLI 如何向 Colab control plane 验证身份:
--authbash
colab --auth oauth2 sessions
colab --auth adc sessionsoauth2~/.colab-cli-oauth-config.json-c PATH在原版上游中,issue #116 仍是一个 granular-consent 缺陷:部分授权可能导致初始登录或后续刷新失败。统一 fork 通过持久化已授予的 scopes、在不重新扩展请求的情况下恢复它们、仅放宽 token exchange 并只要求 control-plane scopes 来修复该问题。
adcbash
gcloud auth application-default login --scopes=openid,https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/userinfo.email,https://www.googleapis.com/auth/colaboratory不要混淆 CLI control-plane 身份验证与 。 子命令会将凭据推送到远端 VM,供需要 BigQuery 或 Cloud Storage 等 GCP 服务的 notebook 代码使用。
colab authcolab auth可使用以下命令调试 control-plane 身份和 scopes:
bash
colab whoami
colab --auth adc whoamiauthwhoamicolab --helpwhoamiauth对于 control-plane 401/403 错误,先运行 并检查当前 provider 和 scopes。当前 session 分配使用 ;不要使用已过时的 keep-alive 故障排查方法。
colab whoamicolab.research.google.comcolab.pa.googleapis.comOne-Shot Jobs
一次性任务
Use when the user wants a script run on temporary hardware:
colab runbash
colab run --gpu T4 train.py --epochs 1Useful options:
bash
colab run --gpu T4 script.py
colab run --gpu L4 --timeout 600 script.py
colab run --tpu v5e1 script.py
colab run --gpu T4 --env EPOCHS=1 train.py
colab run --keep -s inspect-job script.pyDefault execution timeout is 30.0s; pass an explicit for long jobs.
is repeatable; if the same key is supplied more than once,
the last value wins. Use it only for non-secret values on stock upstream because expanded
environment assignments can be persisted in local session history.
--timeout--env KEY=VALUEUse only when you need to inspect the runtime afterward. If you use it,
stop the session explicitly:
--keepbash
colab stop -s inspect-jobFor executable scripts, a shebang can request Colab hardware:
python
#!/usr/bin/env -S colab run --gpu T4
print("running remotely")Operational details:
- forwards script arguments and sets
colab runlike local__name__ == "__main__".python script.py - Script exit codes propagate. An exception or makes
sys.exit(1)return non-zero.colab run - CLI status chatter goes to stderr; the script's stdout stays on stdout. This
makes capture only the script output.
colab run job.py > out.txt - Exception: the CLI prints a once-daily upgrade banner
() to stdout before command output on non-display subcommands, including
[colab] A new version ...,run,exec, andnew. When parsing captured stdout, ignore leadingsessions-prefixed lines, or silence the check with[colab]in"enable_update_check": false.~/.config/colab-cli/settings.json - A missing script path fails before VM allocation.
当用户希望在临时硬件上运行脚本时,使用 :
colab runbash
colab run --gpu T4 train.py --epochs 1常用选项:
bash
colab run --gpu T4 script.py
colab run --gpu L4 --timeout 600 script.py
colab run --tpu v5e1 script.py
colab run --gpu T4 --env EPOCHS=1 train.py
colab run --keep -s inspect-job script.py默认执行超时为 30.0s;长时间任务请显式传入 。 可重复使用;如果多次提供同一个 key,则最后一个值生效。在原版上游中,仅将其用于非 secret 值,因为展开后的环境变量赋值可能会保存在本地 session history 中。
--timeout--env KEY=VALUE仅当需要事后检查 runtime 时才使用 。如果使用,请明确停止 session:
--keepbash
colab stop -s inspect-job对于可执行脚本,可以通过 shebang 请求 Colab 硬件:
python
#!/usr/bin/env -S colab run --gpu T4
print("running remotely")操作细节:
- 会转发脚本参数,并像本地
colab run一样设置python script.py。__name__ == "__main__" - 脚本 exit code 会向上传递。异常或 会使
sys.exit(1)返回非零状态。colab run - CLI 状态信息会写入 stderr;脚本 stdout 保持为 stdout。因此,只会捕获脚本输出。
colab run job.py > out.txt - 例外情况:CLI 每天最多一次会在非 display 子命令(包括 、
run、exec和new)的输出之前,将升级提示横幅(sessions)打印到 stdout。解析捕获的 stdout 时,应忽略开头的[colab] A new version ...前缀行,或者在[colab]中设置~/.config/colab-cli/settings.json来禁用检查。"enable_update_check": false - 如果脚本路径不存在,则会在分配 VM 之前失败。
Multi-Step Sessions
多步骤 Session
Use a named session for setup, multiple runs, file transfer, or log export:
bash
colab new -s trainer --gpu T4
colab status -s trainer
colab install -s trainer torch transformers datasets peft trl accelerate
colab exec -s trainer -f train.py --timeout 1800
colab download -s trainer /content/outputs/adapter.safetensors ./adapter.safetensors
colab log -s trainer -o trainer-log.ipynb
colab stop -s trainer
colab sessionsAvailable accelerators reported by the CLI:
- GPU: ,
T4,L4,G4,H100A100 - TPU: ,
v5e1v6e1
Availability depends on the user's Colab subscription and remaining compute
units. If a high-end GPU fails, retry with a cheaper option such as only
after explaining the tradeoff.
T4If an accelerator request returns a quota or entitlement error, fall back to
or CPU only after checking the user's goal. Do not assume GPU/TPU
allocation will succeed on every account. If the error indicates exhausted
compute units or an expired subscription, suggest , which opens the
Colab subscription page in a browser.
--gpu T4colab pay当需要环境准备、多次运行、文件传输或日志导出时,使用命名 session:
bash
colab new -s trainer --gpu T4
colab status -s trainer
colab install -s trainer torch transformers datasets peft trl accelerate
colab exec -s trainer -f train.py --timeout 1800
colab download -s trainer /content/outputs/adapter.safetensors ./adapter.safetensors
colab log -s trainer -o trainer-log.ipynb
colab stop -s trainer
colab sessionsCLI 报告的可用 accelerator:
- GPU:、
T4、L4、G4、H100A100 - TPU:、
v5e1v6e1
可用性取决于用户的 Colab 订阅和剩余 compute unit。如果高端 GPU 分配失败,请先说明取舍,再尝试成本较低的选项,例如 。
T4如果 accelerator 请求返回 quota 或 entitlement 错误,请先确认用户目标,再回退到 或 CPU。不要假定 GPU/TPU 分配在每个账户上都会成功。如果错误表明 compute unit 已耗尽或订阅已过期,请建议使用 ,它会在浏览器中打开 Colab 订阅页面。
--gpu T4colab payExecution
执行
Run local Python code on an existing session:
bash
colab exec -s analysis -f script.py --timeout 300
colab exec -s analysis --env BATCH=32 -f script.pyDefault execution timeout is 30.0s; pass an explicit for long jobs.
is repeatable here too, with the last duplicate key winning.
Do not pass secrets through this flag on stock upstream because values can be
written into local execution history.
--timeout--env KEY=VALUEPipe short code through stdin:
bash
printf '%s\n' "import torch; print(torch.cuda.is_available())" | colab exec -s analysisRun a notebook against the remote kernel:
bash
colab exec -s analysis -f notebook.ipynb --timeout 900
colab log -s analysis -o analysis-log.ipynbNotebook execution writes an output notebook next to the input, and
can export the session history separately.
colab log -oFor plots, pass to or when you need a
deterministic local image path.
--output-image <path>execreplFor batch shell commands, prefer Python through when possible. If a real
shell is required:
execbash
printf '%s\n' "pwd; ls -la /content" | colab console -s analysisconsole在已有 session 上运行本地 Python 代码:
bash
colab exec -s analysis -f script.py --timeout 300
colab exec -s analysis --env BATCH=32 -f script.py默认执行超时为 30.0s;长时间任务请显式传入 。这里的 同样可以重复使用,重复 key 以最后一个为准。在原版上游中,不要通过此 flag 传递 secret,因为这些值可能会被写入本地执行 history。
--timeout--env KEY=VALUE通过 stdin 传入短代码:
bash
printf '%s\n' "import torch; print(torch.cuda.is_available())" | colab exec -s analysis针对远程 kernel 运行 notebook:
bash
colab exec -s analysis -f notebook.ipynb --timeout 900
colab log -s analysis -o analysis-log.ipynbNotebook 执行会在输入文件旁写入输出 notebook,而 可以单独导出会话历史。
colab log -o对于绘图,如果需要确定性的本地图像路径,请向 或 传入 。
execrepl--output-image <path>对于批量 shell 命令,应尽可能优先通过 运行 Python。如果确实需要真实 shell:
execbash
printf '%s\n' "pwd; ls -la /content" | colab console -s analysisconsoleRemote Shell Access
远程 Shell 访问
colab ssh -s <name>colab ssh-s--gpu--tpu--high-mem--rmcolab ssh--proxy-modeProxyCommand colab ssh --proxy-mode -s SESS~/.ssh/config-s SESS--rm-i/--identity~/.ssh/id_ed25519~/.ssh/id_ecdsacolab ssh -s <name>colab ssh-s--gpu--tpu--high-mem--rmcolab ssh--proxy-mode~/.ssh/configProxyCommand colab ssh --proxy-mode -s SESS-s SESS--rm-i/--identity~/.ssh/id_ed25519~/.ssh/id_ecdsaFiles And Environment
文件与环境
Remote filesystem commands:
bash
colab ls -s analysis /content
colab upload -s analysis ./local.txt /content/local.txt
colab download -s analysis /content/result.json ./result.json
colab rm -s analysis /content/temp.txt
colab edit -s analysis /content/config.pyOn current stock upstream, prefer an explicit
sequence for valuable existing files instead of . The released
catches any download exception as if the remote file did not
exist; a transient transport/auth failure can therefore open an empty temp file
and later overwrite the remote path if the user saves changes.
download -> local edit -> uploadcolab editcolab editInstall packages on the VM:
bash
colab install -s analysis numpy pandas
colab install -s analysis -r requirements.txtOn the unified fork, prefer persistent DriveFS for repeat/agent workflows:
bash
undefined远程文件系统命令:
bash
colab ls -s analysis /content
colab upload -s analysis ./local.txt /content/local.txt
colab download -s analysis /content/result.json ./result.json
colab rm -s analysis /content/temp.txt
colab edit -s analysis /content/config.py在当前原版上游中,对于重要的现有文件,优先采用明确的 流程,而不要使用 。已发布的 会将任何 download 异常都视为远端文件不存在;因此,临时传输或身份验证故障可能会打开一个空的临时文件,并可能在用户保存更改后覆盖远端路径。
download -> 本地 edit -> uploadcolab editcolab edit在 VM 上安装软件包:
bash
colab install -s analysis numpy pandas
colab install -s analysis -r requirements.txt在统一 fork 中,对于重复执行或 Agent 工作流,请优先使用持久化 DriveFS:
bash
undefinedOne-time user-owned authorization and private Desktop-client installation.
One-time user-owned authorization and private Desktop-client installation.
colab drive-mount login --client-config /path/to/client_secret.json
colab drive-mount login --client-config /path/to/client_secret.json
Every later runtime can mount without repeating browser consent.
Every later runtime can mount without repeating browser consent.
colab new -s analysis
colab drive-mount -s analysis
colab drive-mount status
The fork stores the Desktop OAuth client at `~/.config/colab-cli/drive-mount-client.json` and the refresh grant at `drive-mount-auth.json`, both with user-only permissions. Per-shell OAuth environment configuration is optional rather than required. If a desktop browser cannot be discovered, login prints a loopback URL instead of failing; open it on the same machine because its callback is localhost. `colab drivemount -s analysis` automatically uses the persistent path when configured, otherwise it falls back to stock interactive behavior. Use `colab drive-mount logout` to revoke/remove the refresh grant. Stock upstream issue #113 still affects the legacy interactive path, so verify mounts before depending on it.colab new -s analysis
colab drive-mount -s analysis
colab drive-mount status
该 fork 将 Desktop OAuth client 存储在 `~/.config/colab-cli/drive-mount-client.json`,将 refresh grant 存储在 `drive-mount-auth.json`,二者均仅允许用户访问。每个 shell 的 OAuth 环境配置是可选的,而不再是必需。如果无法发现桌面浏览器,login 会打印 loopback URL 而不是直接失败;请在同一台机器上打开该 URL,因为 callback 指向 localhost。`colab drivemount -s analysis` 会在配置完成时自动使用持久化路径,否则回退到原版交互行为。使用 `colab drive-mount logout` 撤销或移除 refresh grant。原版上游的 issue #113 仍会影响旧版交互路径,因此请先验证挂载是否成功,再依赖该功能。Drive API quota and transfer guidance
Drive API 配额与传输指南
For large Drive-backed Colab jobs, read before estimating transfer safety or cost. For projects on Google's standardized 2026 Drive API quotas, remember the headline limits: 1 TB/day project egress, 750 GB/day Workspace upload+copy, 1,000,000 quota units/min/project, 325,000/min/user/project, and a 400,000,000 quota-unit/day no-additional-charge threshold. Drive -> Colab is the egress direction; Colab -> Drive is upload/ingress. Treat exact DriveFS byte accounting as unverified unless the project's Cloud quota telemetry confirms it, because Google's public quota page does not explicitly document one-for-one DriveFS accounting. Grandfathered projects can retain older quotas.
references/drive-api-limits-2026-10-01.md对于大型 Drive-backed Colab 任务,在估算传输安全性或成本之前,请阅读 。对于采用 Google 2026 年标准化 Drive API 配额的项目,请记住以下主要限制:每项目每天 1 TB egress、每 Workspace 每天 750 GB upload+copy、每项目每分钟 1,000,000 个 quota unit、每用户每项目每分钟 325,000 个以及每天 400,000,000 个 quota unit 的免额外收费阈值。Drive -> Colab 属于 egress 方向;Colab -> Drive 属于 upload/ingress。除非项目的 Cloud quota telemetry 予以确认,否则请将 DriveFS 的精确字节计数视为未经验证,因为 Google 的公开配额页面没有明确说明 DriveFS 是否采用 1:1 计数。存量项目可能会继续沿用旧配额。
references/drive-api-limits-2026-10-01.mdLogs And Reporting
日志与报告
Inspect and save execution history:
bash
colab log -s analysis -n 20
colab log -s analysis -t execution
colab log -s analysis -o analysis-log.ipynb
colab log -s analysis -o analysis-log.md
colab log -s analysis -o analysis-log.txt
colab log -s analysis -o analysis-log.jsonlThe suffix picks the export format: , , , or .
-o.ipynb.md.txt.jsonlUse for per-command options and defaults; it is
equivalent to .
colab help <command>colab <command> --helpWhen reporting completion, include the session name, hardware, files retrieved,
log file path if exported, and confirmation that cleanup ran.
检查和保存执行历史:
bash
colab log -s analysis -n 20
colab log -s analysis -t execution
colab log -s analysis -o analysis-log.ipynb
colab log -s analysis -o analysis-log.md
colab log -s analysis -o analysis-log.txt
colab log -s analysis -o analysis-log.jsonl-o.ipynb.md.txt.jsonl使用 查看各命令的选项和默认值;它等价于 。
colab help <command>colab <command> --help报告任务完成情况时,请包含 session 名称、硬件、已取回的文件、导出后的日志文件路径,以及清理是否已执行的确认信息。
Recovery
恢复
- Treat as sensitive. Besides executed code and outputs, current stock upstream records raw interactive stdin replies, which can include one-time auth codes or other secrets. Do not publish/export history without reviewing and redacting it first.
~/.config/colab-cli/history/ - : run
Session not foundbefore recreating anything. If the backend assignment is gone, recreate as needed. If an unnamed/colab sessionsassignment or the recorded endpoint is still live, treat it as an orphaned local record and recover/stop that assignment instead of allocating a duplicate. See[?].references/session-resilience-2026-10-01.md - Kernel stuck or timeout: run once, then retry. If still stuck, stop and recreate the session.
colab restart-kernel -s <name> - Unexpected stale behavior: check and
which colab.colab version - Auth failure: inspect whether the command used or
oauth2, then runadc; do not usecolab whoamito fix control-plane credential problems.colab auth - Cleanup uncertainty: run and reconcile all assignments created for the current task, including unnamed/orphaned endpoints; do not treat named-session disappearance as successful cleanup.
colab sessions - For paid long jobs, use a detached spend watchdog with CU cap, account floor, wall deadline, bounded usage probes, and stop fallback. Parse numeric CLI output under ; locale decimal commas can silently break awk/printf comparisons. Kill watchdog/helper processes by recorded PID, not broad patterns. Detailed field-tested design:
LC_ALL=C.references/session-resilience-2026-10-01.md
- 请将 视为敏感目录。除了已执行代码和输出,当前原版上游还会记录原始交互式 stdin 回复,其中可能包含一次性 auth code 或其他 secret。未经检查和脱敏,不要发布或导出 history。
~/.config/colab-cli/history/ - :在重新创建任何资源之前,先运行
Session not found。如果后端分配已经消失,请按需重新创建。如果未命名或colab sessions的分配、已记录的 endpoint 仍然存活,请将其视为孤立的本地记录,并恢复或停止该分配,而不是分配重复资源。参见[?]。references/session-resilience-2026-10-01.md - Kernel 卡住或超时:运行一次 ,然后重试。如果仍然卡住,请停止并重新创建 session。
colab restart-kernel -s <name> - 出现意外的陈旧行为:检查 和
which colab。colab version - 身份验证失败:检查命令使用的是 还是
oauth2,然后运行adc;不要使用colab whoami修复 control-plane 凭据问题。colab auth - 不确定是否已清理:运行 ,并核对当前任务创建的所有分配,包括未命名或孤立 endpoint;不要将命名 session 消失视为清理成功。
colab sessions - 对于付费的长时间任务,请使用分离的支出 watchdog,并设置 CU cap、账户余额下限、墙钟截止时间、有时限的用量探测和停止 fallback。请在 下解析数值型 CLI 输出;locale 使用小数逗号时可能会悄悄破坏 awk/printf 比较。应按照记录的 PID 终止 watchdog 和 helper 进程,不要使用宽泛的 pattern。详细且经过实战验证的设计参见
LC_ALL=C。references/session-resilience-2026-10-01.md
Stock upstream vs unified fork
原版上游与统一 fork
Stock upstream still has the broad-download exception risk, broad Contents 404 classification, ambiguous assignment POST timeout handling, locally cached machine shape, and destructive local pruning after a single missing-assignment listing. The unified fork fixes these: safe , proxy 401/404 classification, bounded assignment reconciliation, backend , and in () retry + private stale-session storage + automatic re-adoption + stale endpoint stop fallback + same-name stale cleanup. Keep as the final server-side resource source of truth. Do not reinstall an older live job mid-run just to gain the new recovery logic; retain its existing external guard until a safe stop/checkpoint boundary.
colab editstatuseditmachineShapec7512ab0.7.5.dev13+gc7512abedcolab sessions原版上游仍存在 宽泛 download 异常风险、宽泛的 Contents 404 分类、模糊的分配 POST timeout 处理、本地缓存的 machine shape,以及在单次缺失分配列表后执行破坏性本地清理等问题。统一 fork 修复了这些问题:安全的 、proxy 401/404 分类、有界的分配记录核对、后端 ,并在 ()中加入 retry + 私有 stale-session storage + 自动重新接管 + stale endpoint 停止 fallback + 同名 stale 清理。请始终将 作为服务器端资源状态的最终事实来源。不要在任务运行中途仅为获得新的恢复逻辑而重新安装旧版本;请保留现有的外部 guard,直到安全的 stop/checkpoint 边界。
colab editstatuseditmachineShapec7512ab0.7.5.dev13+gc7512abedcolab sessionsFast Command Reference
快速命令参考
bash
colab new -s NAME [--gpu T4|L4|G4|H100|A100] [--tpu v5e1|v6e1] [--high-mem]
colab sessions
colab status -s NAME
colab run [--gpu GPU|--tpu TPU] [--high-mem] [--keep] [--env KEY=VALUE]... SCRIPT [ARGS...]
colab exec -s NAME -f FILE [--timeout SECONDS] [--env KEY=VALUE]...
colab install -s NAME PKG...
colab install -s NAME -r requirements.txt
colab upload -s NAME LOCAL REMOTE
colab download -s NAME REMOTE LOCAL
colab log -s NAME [-n N|-o FILE]
colab restart-kernel -s NAME
colab url -s NAME [--open] [--host HOST]
colab ssh [-s NAME] [--proxy-mode] [-i KEY] [--gpu GPU] [--tpu TPU] [--high-mem] [--rm]
colab stop -s NAME
colab usage
colab help [COMMAND]
colab pay
colab skill
colab readme
colab whoami
colab versionFor upstream details, consult:
- Google Developers Blog announcement:
https://developers.googleblog.com/introducing-the-google-colab-cli/ - Google Colab CLI repository:
https://github.com/googlecolab/google-colab-cli
bash
colab new -s NAME [--gpu T4|L4|G4|H100|A100] [--tpu v5e1|v6e1] [--high-mem]
colab sessions
colab status -s NAME
colab run [--gpu GPU|--tpu TPU] [--high-mem] [--keep] [--env KEY=VALUE]... SCRIPT [ARGS...]
colab exec -s NAME -f FILE [--timeout SECONDS] [--env KEY=VALUE]...
colab install -s NAME PKG...
colab install -s NAME -r requirements.txt
colab upload -s NAME LOCAL REMOTE
colab download -s NAME REMOTE LOCAL
colab log -s NAME [-n N|-o FILE]
colab restart-kernel -s NAME
colab url -s NAME [--open] [--host HOST]
colab ssh [-s NAME] [--proxy-mode] [-i KEY] [--gpu GPU] [--tpu TPU] [--high-mem] [--rm]
colab stop -s NAME
colab usage
colab help [COMMAND]
colab pay
colab skill
colab readme
colab whoami
colab version有关上游详情,请参阅:
- Google Developers Blog 公告:
https://developers.googleblog.com/introducing-the-google-colab-cli/ - Google Colab CLI repository:
https://github.com/googlecolab/google-colab-cli