lightning-studios
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLightning AI Studios
Lightning AI Studios
A Studio is a persistent cloud development machine on lightning.ai. Its filesystem persists across sessions; compute (CPU/GPU) attaches on start and detaches on stop. Everything below uses the CLI and Python package.
lightninglightning_sdkStudio 是 lightning.ai 上的持久化云端开发机。其文件系统在不同会话间保持持久化;计算资源(CPU/GPU)会在启动时挂载,停止时卸载。以下所有操作均使用 CLI 和 Python 包。
lightninglightning_sdkSetup & auth
设置与身份验证
bash
undefinedbash
undefinedUse the Lightning AI CLI from the current env; install or upgrade it there if it's missing or older than 2026.9.18
Use the Lightning AI CLI from the current env; install or upgrade it there if it's missing or older than 2026.9.18
v=$(lightning --version 2>/dev/null | sed -n 's/^Lightning CLI version //p')
[ -n "$v" ] && [ "$(printf '%s\n' 2026.9.18 "$v" | sort -V | head -1)" = 2026.9.18 ]
|| uv pip install -U lightning-sdk || python3 -m pip install -U lightning-sdk lightning --version # must print "Lightning CLI version …"; if not, see the table below lightning login # browser flow; or set env vars for headless use: export LIGHTNING_API_KEY=... LIGHTNING_USER_ID=... # USER_ID optional: with it Basic auth, without it the key is a Bearer token
|| uv pip install -U lightning-sdk || python3 -m pip install -U lightning-sdk lightning --version # must print "Lightning CLI version …"; if not, see the table below lightning login # browser flow; or set env vars for headless use: export LIGHTNING_API_KEY=... LIGHTNING_USER_ID=... # USER_ID optional: with it Basic auth, without it the key is a Bearer token
This uses, and if needed installs into, the environment the agent runs in (the user's project
venv, a conda env, …). Then call plain `lightning …` everywhere. If setup doesn't go cleanly:
| Symptom | Fix |
|---|---|
| Both installs fail: no active env, or pip refuses with `externally-managed-environment` | Install it on its own instead: `uv tool install lightning-sdk` (or `pipx install lightning-sdk`), then call `"$(uv tool dir --bin)/lightning"` if that dir isn't on `PATH` |
| `lightning --version` still prints no `Lightning CLI version` line after installing | `command -v lightning` shows which one runs. Another tool owns the name (PyTorch Lightning also installs a `lightning` command), or the env you installed into isn't on `PATH`: activate it (`source .venv/bin/activate`) or call its `bin/lightning` by full path |
| `No such command`, `No such option` or `unexpected extra argument` | The CLI is older than this skill expects: `uv pip install -U lightning-sdk` (or `pip install -U lightning-sdk`) in the env `command -v lightning` points into; `uv tool upgrade lightning-sdk` for a uv tool install |
| The upgrade fails on a version conflict with the project's own pins | Don't fight the pins: install it outside the project with `uv tool install lightning-sdk` and call `"$(uv tool dir --bin)/lightning"` |
| Installing is blocked (read-only env or home, agent sandbox) | Skip it and run each command as `UV_CACHE_DIR="${TMPDIR:-/tmp}/uv" uvx lightning-sdk …` |
| Every call fails on SSL/certificates, even `lightning --version` (`Could not find a suitable TLS CA certificate bundle`), only inside an agent sandbox | A `**/*.pem` read-deny rule is hiding certifi's public CA bundle (`site-packages/certifi/cacert.pem`). Allow that one path; don't disable the sandbox |
Credentials are stored in `~/.lightning/credentials.json`.
The install above also makes `lightning_sdk` importable in that env, so Python snippets run with
its `python`. If the CLI came from a uv tool or `uvx` fallback instead, run one-off scripts with
`uv run --with lightning-sdk python script.py`. For code that stays in the user's project, ask,
then declare `lightning-sdk` as a dependency with the project's own tool (`uv add`, `poetry add`).v=$(lightning --version 2>/dev/null | sed -n 's/^Lightning CLI version //p')
[ -n "$v" ] && [ "$(printf '%s\n' 2026.9.18 "$v" | sort -V | head -1)" = 2026.9.18 ]
|| uv pip install -U lightning-sdk || python3 -m pip install -U lightning-sdk lightning --version # must print "Lightning CLI version …"; if not, see the table below lightning login # browser flow; or set env vars for headless use: export LIGHTNING_API_KEY=... LIGHTNING_USER_ID=... # USER_ID optional: with it Basic auth, without it the key is a Bearer token
|| uv pip install -U lightning-sdk || python3 -m pip install -U lightning-sdk lightning --version # must print "Lightning CLI version …"; if not, see the table below lightning login # browser flow; or set env vars for headless use: export LIGHTNING_API_KEY=... LIGHTNING_USER_ID=... # USER_ID optional: with it Basic auth, without it the key is a Bearer token
此操作会使用 Agent 运行所在的环境(用户的项目 venv、conda 环境等),如有需要也会安装到该环境中。之后所有地方都直接调用 `lightning …` 即可。如果设置过程不顺利,请参考下表:
| 症状 | 解决方法 |
|---|---|
| 两种安装方式都失败:没有激活的环境,或者 pip 以 `externally-managed-environment` 为由拒绝安装 | 改为单独安装:`uv tool install lightning-sdk`(或 `pipx install lightning-sdk`),如果该目录不在 `PATH` 中,则调用 `"$(uv tool dir --bin)/lightning"` |
| 安装后 `lightning --version` 仍然没有输出 `Lightning CLI version` 行 | 用 `command -v lightning` 查看运行的是哪个程序。可能是其他工具占用了这个名称(PyTorch Lightning 也会安装 `lightning` 命令),或者你安装到的环境不在 `PATH` 中:激活该环境(`source .venv/bin/activate`),或者使用完整路径调用其 `bin/lightning` |
| 提示 `No such command`、`No such option` 或 `unexpected extra argument` | CLI 版本低于本 Skill 的要求:在 `command -v lightning` 指向的环境中执行 `uv pip install -U lightning-sdk`(或 `pip install -U lightning-sdk`);如果是 uv tool 安装的,则执行 `uv tool upgrade lightning-sdk` |
| 升级因与项目自身的依赖版本锁定冲突而失败 | 不要强行修改版本锁定:使用 `uv tool install lightning-sdk` 在项目外部安装,并调用 `"$(uv tool dir --bin)/lightning"` |
| 安装被阻止(只读环境或主目录、Agent 沙箱) | 跳过安装,将每个命令改为 `UV_CACHE_DIR="${TMPDIR:-/tmp}/uv" uvx lightning-sdk …` 的形式运行 |
| 即使是 `lightning --version` 也会因 SSL/证书问题失败(`Could not find a suitable TLS CA certificate bundle`),且仅在 Agent 沙箱中出现 | 这是因为 `**/*.pem` 读取拒绝规则隐藏了 certifi 的公共 CA 包(`site-packages/certifi/cacert.pem`)。请允许该路径的访问权限,不要禁用沙箱 |
凭证存储在 `~/.lightning/credentials.json` 中。
上述安装操作还会让 `lightning_sdk` 在该环境中可被导入,因此 Python 代码片段可以用该环境的 `python` 运行。如果 CLI 来自 uv tool 或 `uvx` 备用方案,则使用 `uv run --with lightning-sdk python script.py` 运行一次性脚本。对于要保留在用户项目中的代码,请先询问用户,然后使用项目自身的工具(`uv add`、`poetry add`)将 `lightning-sdk` 声明为依赖项。Resolving org and teamspace (do this first)
确定组织与团队空间(请先执行此操作)
Every studio lives in a teamspace owned by either an organization or a user. Never guess. Resolve in this order:
- Explicit flag (owner = org or user name) /
--teamspace owner/teamspacein Python (the separateTeamspace("owner/teamspace")/org=arguments are deprecated).user= - Env vars ,
LIGHTNING_ORG,LIGHTNING_TEAMSPACE, or config defaults inLIGHTNING_USERNAME(~/.lightning/config.yaml).lightning config get teamspace - Otherwise list the options and ask the user which org/teamspace to use:
bash
lightning api /v1/memberships | jq -r '.memberships[] | [.ownerType, .name, .projectId] | @tsv'Persist the user's choice so they aren't asked again: .
lightning config set teamspace <owner>/<teamspace>From a scoped API key (an agent, no user to ask): gives the teamspace name and the owner id, but needs the owner slug — resolve it via (needs ). Select the entry rather than : the same teamspace is commonly listed twice, once with and once with (identical and ), so index 0 is a coin flip and the row's will not resolve against .
/v1/memberships--teamspace/v1/orgsjqorganization.memberships[0]ownerType: organizationownerType: userprojectIdnameuserownerId/v1/orgsbash
M=$(lightning api /v1/memberships)
ROW=$(echo "$M" | jq -c '[.memberships[] | select(.ownerType=="organization")][0] // .memberships[0]')
TS=$(echo "$ROW" | jq -r .name) # teamspace
OWNER=$(lightning api "/v1/orgs/$(echo "$ROW" | jq -r .ownerId)" | jq -r .name) # owner (org) slug
lightning config set teamspace "$OWNER/$TS" # every command now defaults here; or pass --teamspace "$OWNER/$TS"每个 Studio 都位于由组织或用户拥有的团队空间中。绝对不要猜测。 请按以下顺序确定:
- 显式指定 参数(owner 为组织或用户名)/ 在 Python 中使用
--teamspace owner/teamspace(单独的Teamspace("owner/teamspace")/org=参数已弃用)。user= - 环境变量 、
LIGHTNING_ORG、LIGHTNING_TEAMSPACE,或LIGHTNING_USERNAME中的配置默认值(可通过~/.lightning/config.yaml查看)。lightning config get teamspace - 否则列出所有选项,询问用户要使用哪个组织/团队空间:
bash
lightning api /v1/memberships | jq -r '.memberships[] | [.ownerType, .name, .projectId] | @tsv'保存用户的选择,避免再次询问:。
lightning config set teamspace <owner>/<teamspace>使用受限 API 密钥时(即 Agent 场景,无法询问用户): 会返回团队空间名称和所有者的 ID,但 需要所有者的 slug——需要通过 解析(需要 )。请选择 类型的条目,而不是 :同一个团队空间通常会出现两次,一次是 ,一次是 ( 和 完全相同),因此直接取第0个结果是随机的,而且 行的 无法通过 解析。
/v1/memberships--teamspace/v1/orgsjqorganization.memberships[0]ownerType: organizationownerType: userprojectIdnameuserownerId/v1/orgsbash
M=$(lightning api /v1/memberships)
ROW=$(echo "$M" | jq -c '[.memberships[] | select(.ownerType=="organization")][0] // .memberships[0]')
TS=$(echo "$ROW" | jq -r .name) # teamspace
OWNER=$(lightning api "/v1/orgs/$(echo "$ROW" | jq -r .ownerId)" | jq -r .name) # owner (org) slug
lightning config set teamspace "$OWNER/$TS" # every command now defaults here; or pass --teamspace "$OWNER/$TS"CLI reference
CLI 参考
--teamspaceowner/teamspace--name--teamspacebash
undefined--teamspaceowner/teamspace--name--teamspacebash
undefinedcreate (registers the studio, does NOT attach compute)
create (registers the studio, does NOT attach compute)
lightning studio create --name my-studio --teamspace owner/teamspace [--cloud PROVIDER] [--studio-type TEMPLATE]
lightning studio create --name my-studio --teamspace owner/teamspace [--cloud PROVIDER] [--studio-type TEMPLATE]
start compute (blocking; --create makes it if missing)
start compute (blocking; --create makes it if missing)
lightning studio start --name my-studio --teamspace owner/teamspace --machine CPU [--create] [--interruptible]
lightning studio start --name my-studio --teamspace owner/teamspace --gpus L4:4 # --gpus and --machine are mutually exclusive
lightning studio start --name my-studio --teamspace owner/teamspace --machine CPU [--create] [--interruptible]
lightning studio start --name my-studio --teamspace owner/teamspace --gpus L4:4 # --gpus and --machine are mutually exclusive
manage
manage
lightning studio list --teamspace owner/teamspace [--all] [--sort-by status] # default lists only your studios
lightning studio switch --name my-studio --teamspace owner/teamspace --machine A100 # requires Running studio
lightning studio stop --name my-studio --teamspace owner/teamspace
lightning studio delete my-studio --teamspace owner/teamspace -y # NAME is positional here; -y/--yes: required non-interactively
lightning studio list --teamspace owner/teamspace [--all] [--sort-by status] # default lists only your studios
lightning studio switch --name my-studio --teamspace owner/teamspace --machine A100 # requires Running studio
lightning studio stop --name my-studio --teamspace owner/teamspace
lightning studio delete my-studio --teamspace owner/teamspace -y # NAME is positional here; -y/--yes: required non-interactively
ssh / one-shot connect (create + start + ssh)
ssh / one-shot connect (create + start + ssh)
lightning studio ssh --name my-studio --teamspace owner/teamspace
lightning studio connect my-studio --teamspace owner/teamspace --machine CPU
lightning studio ssh --name my-studio --teamspace owner/teamspace
lightning studio connect my-studio --teamspace owner/teamspace --machine CPU
machine names the CLI accepts (offline list; says nothing about availability)
machine names the CLI accepts (offline list; says nothing about availability)
lightning machine list [--json]
undefinedlightning machine list [--json]
undefinedFiles: lit://
paths
lit://文件:lit://
路径
lit://Studio paths use . Exactly one side of a copy must be ; directories need .
lit://<owner>/<teamspace>/studios/<studio-name>/<path>lit://-rbash
lightning cp ./train.py lit://owner/teamspace/studios/my-studio/train.py # upload
lightning cp -r lit://owner/teamspace/studios/my-studio/logs/ ./logs # download dir
lightning ls lit://owner/teamspace/studios/my-studio # list files (-r recursive, --json)
lightning rm lit://owner/teamspace/studios/my-studio/old.txt [-r] [-f]Studio 的路径使用 格式。复制操作的两端必须恰好有一端是 路径;复制目录需要加 参数。
lit://<owner>/<teamspace>/studios/<studio-name>/<path>lit://-rbash
lightning cp ./train.py lit://owner/teamspace/studios/my-studio/train.py # upload
lightning cp -r lit://owner/teamspace/studios/my-studio/logs/ ./logs # download dir
lightning ls lit://owner/teamspace/studios/my-studio # list files (-r recursive, --json)
lightning rm lit://owner/teamspace/studios/my-studio/old.txt [-r] [-f]Python SDK
Python SDK
python
from lightning_sdk import Machine, Studio, Teamspace
ts = Teamspace("my-org/my-teamspace") # owner/teamspace; org=/user= are deprecated
studio = Studio(name="my-studio", teamspace=ts, create_ok=True) # create_ok=False -> error if missing
studio.start(machine=Machine.CPU) # blocking; interruptible=True for spot pricing
print(studio.status) # NotCreated|Pending|Running|Stopping|Stopped|Completed|Failedpython
from lightning_sdk import Machine, Studio, Teamspace
ts = Teamspace("my-org/my-teamspace") # owner/teamspace; org=/user= are deprecated
studio = Studio(name="my-studio", teamspace=ts, create_ok=True) # create_ok=False -> error if missing
studio.start(machine=Machine.CPU) # blocking; interruptible=True for spot pricing
print(studio.status) # NotCreated|Pending|Running|Stopping|Stopped|Completed|Failedrun commands — studio must be Running
run commands — studio must be Running
out = studio.run("nvidia-smi") # raises RuntimeError on non-zero exit
out, code = studio.run_with_exit_code("pytest -q") # no raise on non-zero
out, code = studio.run_and_detach("python train.py", timeout=30) # keeps running in background
studio.upload_file("train.py", remote_path="train.py") # remote path relative to studio home
studio.download_file("outputs/model.ckpt", "model.ckpt")
studio.upload_folder("./src"); studio.download_folder("outputs/")
studio.switch_machine(Machine.A100) # change machine while running
studio.set_env({"WANDB_API_KEY": "..."}) # env vars; partial=True merges
studio.stop() # releases compute, keeps filesystem
studio.delete()
undefinedout = studio.run("nvidia-smi") # raises RuntimeError on non-zero exit
out, code = studio.run_with_exit_code("pytest -q") # no raise on non-zero
out, code = studio.run_and_detach("python train.py", timeout=30) # keeps running in background
studio.upload_file("train.py", remote_path="train.py") # remote path relative to studio home
studio.download_file("outputs/model.ckpt", "model.ckpt")
studio.upload_folder("./src"); studio.download_folder("outputs/")
studio.switch_machine(Machine.A100) # change machine while running
studio.set_env({"WANDB_API_KEY": "..."}) # env vars; partial=True merges
studio.stop() # releases compute, keeps filesystem
studio.delete()
undefinedMachine types
机器类型
Pass as or string ( accepts name or slug):
Machine.<NAME>Machine.from_str("A100")- CPU: ,
CPU_SMALL(default, 4 cores),CPU; big-disk:CPU_X_2/4/8/16,DATA_PREP,DATA_PREP_MAXDATA_PREP_ULTRA - GPU: ,
T4_SMALL,T4,T4_X_2/4/8,L4,L4_X_2/4/8,L40S,L40S_X_2/4/8(+RTXP_6000),_X_2/4/8(+A100),_X_2/4/8(+H100),_X_2/4/8(+H200),_X_2/4/8,B200B200_X_8 - /
A100_40GB*variants exist in the SDK but are hidden from CLIA100_80GB*(usable with--machineand in Python).studio switch
The names above are current as of writing and SKUs do get added, so treat the list as a starting
point, not a closed set. prints the names your installed CLI accepts, but
it is an offline list and says nothing about what a teamspace can launch. For live availability
and prices, use in Python (drops out-of-capacity
machines; each has /) or
(no auth needed, so plain works; the
skill has the provider values and the costing recipes). Don't invent a
catalog endpoint: , , and
all return .
lightning machine listTeamspace("owner/teamspace").list_machines()costinterruptible_costGET /v1/core/accelerators?cloudProvider=<PROVIDER>curllightning-cost-estimation/v1/accelerators/v1/accelerator-catalog/v1/pricing/v1/compute/acceleratorscode: 5Interruptible (spot) is a flag, not a machine type: / .
--interruptibleinterruptible=True可通过 或字符串形式传递( 支持名称或 slug):
Machine.<NAME>Machine.from_str("A100")- CPU:、
CPU_SMALL(默认,4 核)、CPU;大磁盘型:CPU_X_2/4/8/16、DATA_PREP、DATA_PREP_MAXDATA_PREP_ULTRA - GPU:、
T4_SMALL、T4、T4_X_2/4/8、L4、L4_X_2/4/8、L40S、L40S_X_2/4/8(+RTXP_6000)、_X_2/4/8(+A100)、_X_2/4/8(+H100)、_X_2/4/8(+H200)、_X_2/4/8、B200B200_X_8 - SDK 中存在 /
A100_40GB*变体,但在 CLI 的A100_80GB*参数中被隐藏(可通过--machine和 Python 代码使用)。studio switch
上述名称是撰写本文时的当前版本,SKU 会不断新增,因此请将此列表作为起点,而非完整集合。 会输出你安装的 CLI 支持的名称,但这是一个离线列表,无法反映团队空间实际可启动的机器类型。如需实时可用性和价格信息,请在 Python 中使用 (会排除容量不足的机器;每个机器都有 / 字段),或调用 (无需身份验证,因此直接用 即可; Skill 包含提供商值和成本计算方法)。不要自行编造目录端点:、、 和 都会返回 。
lightning machine listTeamspace("owner/teamspace").list_machines()costinterruptible_costGET /v1/core/accelerators?cloudProvider=<PROVIDER>curllightning-cost-estimation/v1/accelerators/v1/accelerator-catalog/v1/pricing/v1/compute/acceleratorscode: 5可中断(竞价实例)是一个标志,而非机器类型:对应参数为 / 。
--interruptibleinterruptible=TrueExample workflows
示例工作流
Prompts this skill handles: "spin up a GPU studio and run my training script", "copy this repo to my studio and start a long run", "SSH into exp-studio", "my studio is idle, stop it".
Create a studio, run a script, collect results, stop (cheap default: start on CPU, switch to GPU only for the run):
bash
lightning studio start --name exp-1 --teamspace my-org/my-teamspace --machine CPU --create
lightning cp -r ./src lit://my-org/my-teamspace/studios/exp-1/src/
lightning studio switch --name exp-1 --teamspace my-org/my-teamspace --machine L4python
from lightning_sdk import Studio
studio = Studio("exp-1", teamspace="my-org/my-teamspace")
out, code = studio.run_with_exit_code("cd ~/src && pip install -r requirements.txt && python train.py")
print(out)bash
lightning cp -r lit://my-org/my-teamspace/studios/exp-1/src/outputs/ ./outputs
lightning studio stop --name exp-1 --teamspace my-org/my-teamspaceSSH in and run scripts interactively (for a human user; agents should prefer above since opens an interactive shell):
studio.run*sshbash
lightning studio ssh --name exp-1 --teamspace my-org/my-teamspace # interactive shell
lightning ssh configure --name exp-1 --teamspace my-org/my-teamspace # writes ~/.ssh/config Host block...
ssh exp-1 'python ~/src/eval.py' # ...then plain ssh runs one-off commands
lightning studio connect exp-1 --teamspace my-org/my-teamspace --machine CPU # create+start+ssh in one shotKick off a long run and detach (survives your session; studio keeps billing until stopped):
python
out, code = studio.run_and_detach("cd ~/src && nohup python train.py > train.log 2>&1", timeout=30)本 Skill 可处理的提示示例:"启动一个 GPU Studio 并运行我的训练脚本"、"把这个仓库复制到我的 Studio 并启动一个长时间运行的任务"、"通过 SSH 连接到 exp-studio"、"我的 Studio 空闲了,停止它"。
创建 Studio、运行脚本、收集结果、停止(低成本默认方案:先在 CPU 上启动,仅在运行时切换到 GPU):
bash
lightning studio start --name exp-1 --teamspace my-org/my-teamspace --machine CPU --create
lightning cp -r ./src lit://my-org/my-teamspace/studios/exp-1/src/
lightning studio switch --name exp-1 --teamspace my-org/my-teamspace --machine L4python
from lightning_sdk import Studio
studio = Studio("exp-1", teamspace="my-org/my-teamspace")
out, code = studio.run_with_exit_code("cd ~/src && pip install -r requirements.txt && python train.py")
print(out)bash
lightning cp -r lit://my-org/my-teamspace/studios/exp-1/src/outputs/ ./outputs
lightning studio stop --name exp-1 --teamspace my-org/my-teamspace通过 SSH 连接并交互式运行脚本(适用于人类用户;Agent 应优先使用上述 方法,因为 会打开交互式 shell):
studio.run*sshbash
lightning studio ssh --name exp-1 --teamspace my-org/my-teamspace # interactive shell
lightning ssh configure --name exp-1 --teamspace my-org/my-teamspace # writes ~/.ssh/config Host block...
ssh exp-1 'python ~/src/eval.py' # ...then plain ssh runs one-off commands
lightning studio connect exp-1 --teamspace my-org/my-teamspace --machine CPU # create+start+ssh in one shot启动长时间运行任务并断开连接(任务不会随会话结束而终止;Studio 会持续计费直到停止):
python
out, code = studio.run_and_detach("cd ~/src && nohup python train.py > train.log 2>&1", timeout=30)later: studio.run("tail -20 ~/src/train.log")
later: studio.run("tail -20 ~/src/train.log")
undefinedundefinedRaw API fallback
原生 API 备用方案
For anything the CLI doesn't wrap, makes an authenticated request ( method, typed field, string field, jq filter):
lightning api <path>-X-F-f-qbash
lightning api /v1/memberships -q '.memberships[].name'
PROJECT_ID=$(lightning api /v1/memberships | jq -r '.memberships[] | select(.name=="<teamspace>") | .projectId' | head -1)对于 CLI 没有封装的操作, 可以发起已认证的请求( 指定请求方法, 指定类型字段, 指定字符串字段, 指定 jq 过滤器):
lightning api <path>-X-F-f-qbash
lightning api /v1/memberships -q '.memberships[].name'
PROJECT_ID=$(lightning api /v1/memberships | jq -r '.memberships[] | select(.name=="<teamspace>") | .projectId' | head -1)studios are "cloudspaces" in the API — one word, and call it BARE (see Gotchas)
studios are "cloudspaces" in the API — one word, and call it BARE (see Gotchas)
lightning api "/v1/projects/${PROJECT_ID}/cloudspaces" -q '.cloudspaces[].name'
undefinedlightning api "/v1/projects/${PROJECT_ID}/cloudspaces" -q '.cloudspaces[].name'
undefinedGotchas
注意事项
- Starting compute costs money; GPU machines cost more. Prefer for setup work, switch to GPU only when needed, and stop studios when done. Ask before starting expensive machines (A100/H100/H200/B200) unless the user already specified one.
CPU - methods and
run*require statusstudio switch;Runningon a studio already running on a different machine raises — usestart()instead.switch_machine - Disabling auto-sleep () or setting
studio.auto_sleep = Falseconverts a free CPU studio to paid.auto_sleep_time - does not attach compute;
studio createdoes both.studio start --create - prompts for confirmation — pass
lightning studio delete/-ynon-interactively. Without it, a scripted or agent-run delete reads the prompt from a closed stdin, prints--yesand exits without deleting, leaving the studio (and its billing) alive. Confirm with the user first, then passAre you sure you want to delete? [y/N]: Aborted.; there is no need to drop into the Python SDK for this.-y - The studios list endpoint is , one word, and takes no
/cloudspacesfields. The hyphenated-Freturns/v1/projects/{pid}/cloud-spaces. Once corrected, addingHTTP 404 Not Foundstill fails with-F limit=20, becauseHTTP 400 Bad Requestsends any request withlightning api/-ffields and no-Fas a POST (the create call). Call it bare and slice with-X, or pass-qto send the fields as query params.-X GET - Inside a Studio, with no args resolves to the current studio (via
Studio()).LIGHTNING_CLOUD_SPACE_ID - In Python, takes the same
teamspace=string as the CLI"owner/teamspace"flag (for--teamspace,TeamspaceandStudio). The separateJob/org=arguments still work but are deprecated and emit auser=; passing both forms raisesDeprecationWarning.ValueError
- 启动计算资源会产生费用;GPU 机器费用更高。设置工作请优先使用 ,仅在需要时切换到 GPU,并且用完后请停止 Studio。启动昂贵的机器(A100/H100/H200/B200)前请先询问用户,除非用户已经指定了机型。
CPU - 方法和
run*要求 Studio 状态为studio switch;对已经在其他机器上运行的 Studio 调用Running会报错——请改用start()。switch_machine - 禁用自动休眠()或设置
studio.auto_sleep = False会将免费的 CPU Studio 转为付费模式。auto_sleep_time - 不会挂载计算资源;
studio create会同时完成创建和启动。studio start --create - 会提示确认——非交互式场景下请传递
lightning studio delete/-y参数。 如果不加该参数,脚本或 Agent 执行删除操作时会从已关闭的标准输入读取提示,输出--yes后退出,并未实际删除,导致 Studio(及其计费)继续存在。请先与用户确认,然后传递Are you sure you want to delete? [y/N]: Aborted.参数;无需为此使用 Python SDK。-y - Studio 列表的端点是 (一个单词),且不接受
/cloudspaces字段。 带连字符的-F会返回/v1/projects/{pid}/cloud-spaces。即使路径改对了,加上HTTP 404 Not Found仍然会失败并返回-F limit=20,因为HTTP 400 Bad Request会将任何带有lightning api/-f字段且没有指定-F的请求作为 POST(创建请求)发送。请直接调用该端点并用-X截取结果,或者传递-q将字段作为查询参数发送。-X GET - 在 Studio 内部,不带参数的 会解析为当前 Studio(通过
Studio())。LIGHTNING_CLOUD_SPACE_ID - 在 Python 中,参数接受与 CLI
teamspace=标志相同的--teamspace字符串(适用于"owner/teamspace"、Teamspace和Studio)。单独的Job/org=参数仍然可用,但已弃用并会发出user=;同时传递两种形式会抛出DeprecationWarning。ValueError