Compute
code-server
启动这个模板,你会在浏览器里得到一个完整的 VS Code 窗口,跑在租来的机器上,集成终端里就能用 GPU。
你会得到什么
Section titled “你会得到什么”镜像是 grafilab/code-server:4.123.0,即 Coder 的 code-server,改成以 root 运行。
- 80 端口上的 code-server,发布在
https://<your-slug>.instance.grafilab.ai。 HOME设为/root,所以编辑器和 SSH shell 共用一个 home 目录和一套 dotfiles。- GPU 直通,尽管这是个编辑器:集成终端里
nvidia-smi可用,你在那里安装并运行的任何东西也一样。 - 同一容器上通过 SSH 使用的 root shell。
当你想在代码运行的地方编辑它时选它 —— 一个正在 GPU 上调试的仓库、一个只在真实硬件上才失败的脚本 —— 而不必搭本地的远程开发隧道。如果你更愿意用自己笔记本上的编辑器,跳过这个模板,用 VS Code 的 Remote-SSH 连到 PyTorch + CUDA 实例。
部署实例,在第 2 步 Template Selection 里选 code-server。完整流程见部署 GPU 实例。
打开 IDE
Section titled “打开 IDE”-
在控制台打开 My Instance,等卡片显示 Active。
-
打开
https://<your-slug>.instance.grafilab.ai。slug 就是实例卡片上那个三词名字。编辑器会直接加载进一个工作区 —— 不需要登录。 -
打开
/root下的某个目录,或者在终端里克隆一个仓库 —— 见下一节。
使用终端和 GPU
Section titled “使用终端和 GPU”打开 Terminal → New Terminal。你会得到容器里的一个 root shell,和你通过 SSH 连上的是同一个。
nvidia-smigit clone https://github.com/<owner>/<repo>.git这个镜像是编辑器,不是 CUDA 环境,所以你的项目需要什么就装什么:
pip install torchpython -c "import torch; print(torch.__version__, torch.cuda.is_available())"如果你想要现成的 CUDA 和 PyTorch 环境而不是自己搭,用 PyTorch + CUDA 或 JupyterLab 模板,然后通过 Remote-SSH 编辑。
code-server 从 Open VSX 仓库安装扩展,而不是微软的 Visual Studio Marketplace —— 微软的条款把那个市场限制在自家的 VS Code 构建上。大多数开源扩展都在 Open VSX 上;部分微软发布的扩展和少数商业扩展不在。搜不到东西时,通常就是这个原因。
扩展装在容器里,所以它们会和其他一切一起随租期消失。
运行并暴露一个应用
Section titled “运行并暴露一个应用”在集成终端里把你的应用起在任意端口上,绑定到所有网卡,代理才能访问:
python -m http.server 8080 --bind 0.0.0.080 端口被编辑器自己占用了,所以第二个服务需要自己的公网 URL。在控制台打开实例卡片上的 Web Access,添加一条映射,填 Service Name 和你的应用监听的 Port,然后使用它生成的代理 URL —— https://<your-slug>-<service>.instance.grafilab.ai。完整步骤见管理实例。
Anyone with the URL can reach your web UI
The Grafilab proxy does not add a login in front of your instance. Your random three-word slug (https://<your-slug>.instance.grafilab.ai) is the only barrier, and the shipped web templates have no application login of their own (Open WebUI is the exception). Treat the URL like a password: don’t paste it in public places, and if you need a lock, add one inside the app over SSH.
在这个模板上暴露是彻底的:这个 URL 就是一个 root 终端。把它当成密钥,不要让实例开着超过你需要的时间,也不要把 URL 贴到共享频道里。
要真正的锁,code-server 支持 --auth password,密码取自 PASSWORD 环境变量,或 ~/.config/code-server/config.yaml 里的 password。启用它意味着带着这个设置重启服务,这要通过 SSH 来做。
Nothing persists past the rental
Instances have no persistent volume. Anything you write at runtime — downloaded models, installed packages, notebooks, outputs — lives in the container for the lifetime of the rental and is gone when it expires. Before Expire at, back up the folders you care about to Grafilab storage and download the archive.
/root 下的一切 —— 你的工作区、你的扩展、你的 shell 历史 —— 都在容器里。边写边把代码推到 git,不在仓库里的东西用实例卡片上的 Backup。

