# Gpu Vm

> Launch GPU VMs on Google Cloud (GCE) and run commands on them over SSH. Use when the user wants to spin up a cloud GPU instance (L4/T4/V100/A100/H100), train or run code on a remote GPU, push a local repo to a VM, stream remote logs, or manage (create/ssh/stop/delete) GPU VMs. Triggers: "launch a GPU VM", "run this on a cloud GPU", "create an L4/A100 instance", "send commands to the VM".

- **Type:** Skill
- **Install:** `agentstack add skill-alexbodner-gcloud-gpu-agent-gcloud-gpu-agent`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [AlexBodner](https://agentstack.voostack.com/s/alexbodner)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [AlexBodner](https://github.com/AlexBodner)
- **Source:** https://github.com/AlexBodner/gcloud-gpu-agent/tree/main/skills/gcloud-gpu-agent

## Install

```sh
agentstack add skill-alexbodner-gcloud-gpu-agent-gcloud-gpu-agent
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# GPU VM on Google Cloud

Create and drive a GCE GPU VM from the terminal. All actions go through the
bundled `gpu-vm.sh` (a `gcloud` wrapper). Each command runs locally and executes
on the VM via `gcloud compute ssh --command`, so you (Claude) can run jobs and
read their output without an interactive shell.

Call the script as `bash "$CLAUDE_PLUGIN_ROOT/gpu-vm.sh" `.

## Before anything: check prerequisites

These are the user's to do once; you cannot do the interactive login.
```bash
gcloud auth list --filter=status:ACTIVE --format="value(account)"   # must print an account
gcloud config get-value project                                     # must print a project
```
If either is empty, tell the user to run `gcloud auth login` (suggest `! gcloud auth login` in-session) and `gcloud config set project `. If `gcloud` itself is missing: `brew install --cask google-cloud-sdk`.

Also confirm GPU quota before creating (avoids a confusing failure):
```bash
gcloud compute regions describe us-central1 --format="value(quotas)" | tr ';' '\n' | grep -i gpus
```
Quota 0 → the user must request it in IAM & Admin → Quotas (can take time).

## Configuration (env vars)

Set per-invocation; defaults in parentheses:
`NAME` (gpu-vm) · `ZONE` (us-central1-a) · `GPU` (nvidia-l4) · `COUNT` (1) ·
`MACHINE` (auto from GPU) · `DISK_SIZE` (200GB) · `IMAGE_FAMILY`
(common-cu129-ubuntu-2204-nvidia-580) · `IMAGE_PROJECT` (deeplearning-platform-release) ·
`SPOT` (0; set 1 for cheaper preemptible instances).

GPU → machine auto-mapping: `nvidia-l4`→g2-standard-8, `nvidia-tesla-t4`/`-v100`→n1-standard-8,
`nvidia-tesla-a100`→a2-highgpu, `nvidia-a100-80gb`→a2-ultragpu, `nvidia-h100-80gb`→a3-highgpu-8g.
(A2/A3 bundle the GPU; the script omits `--accelerator` for them automatically.)

## Typical flow

```bash
S="$CLAUDE_PLUGIN_ROOT/gpu-vm.sh"
NAME=ml-l4 GPU=nvidia-l4 ZONE=us-central1-a bash "$S" create
NAME=ml-l4 ZONE=us-central1-a bash "$S" status                 # verify nvidia-smi sees the GPU
NAME=ml-l4 ZONE=us-central1-a bash "$S" push ~/path/to/repo    # git archive HEAD → scp (works on PRIVATE repos)
NAME=ml-l4 ZONE=us-central1-a bash "$S" ssh "cd repo && pip install -r requirements.txt"
NAME=ml-l4 ZONE=us-central1-a bash "$S" run "cd repo && python train.py" train   # long job in tmux
NAME=ml-l4 ZONE=us-central1-a bash "$S" logs "repo/train.log"  # tail -f (Ctrl-C to stop)
NAME=ml-l4 ZONE=us-central1-a bash "$S" pull repo/outputs ./outputs
NAME=ml-l4 ZONE=us-central1-a bash "$S" stop                   # or: delete
```

Use **one** zone consistently for a given VM (pass the same `ZONE` every time).

## Commands

`create` · `push  [dest]` · `ssh ""` (one-shot, returns output) ·
`shell` (interactive) · `run "" [session]` (tmux, survives disconnect,
logs to `~/.log`) · `wait [session]` (block until the tmux session ends) ·
`logs ` · `status` (tmux + nvidia-smi) · `pull  [local]` ·
`put  ` · `list` · `start` · `stop` · `delete`.

## Operational notes (learned the hard way)

- **Long jobs:** always use `run` (tmux), never `ssh` for something that takes
  minutes — the SSH command would block. Then poll with `status`/`logs`. For
  multi-minute setup/installs, run the `ssh`/`push` command as a **background**
  Bash task and read its output when notified.
- **First boot:** right after `create`, SSH and `nvidia-smi` need ~1-2 min
  (boot + driver + key propagation). Retry a few times before concluding failure.
- **STOCKOUT** (`does not have enough resources` / `currently unavailable`): the
  GPU is momentarily out of stock in that zone — NOT a quota issue. Retry another
  zone in the same region (quota is regional), e.g. `ZONE=us-central1-c ... create`.
- **Image family not found:** families get retired. Discover current ones:
  `gcloud compute images list --project deeplearning-platform-release --filter="family~cu12" --format="value(family)" | sort -u`
- **Private git repo:** `push` uses `git archive HEAD` + scp, so no GitHub
  credentials are needed on the VM. Only committed files are sent — commit first.
- **Cost (say this to the user):** GPU VMs bill while RUNNING. Always `stop`
  (keeps disk) or `delete` (frees everything) when done. Remind them.
- **Confirm before `delete`** unless the user clearly authorized it.
- **Waiting for a job to finish:** use `wait ` (it checks `tmux
  has-session`). Do NOT hand-roll `while pgrep -f ; do ...` — the wait
  loop's own command line contains ``, so `pgrep -f` matches itself and
  never exits.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [AlexBodner](https://github.com/AlexBodner)
- **Source:** [AlexBodner/gcloud-gpu-agent](https://github.com/AlexBodner/gcloud-gpu-agent)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-alexbodner-gcloud-gpu-agent-gcloud-gpu-agent
- Seller: https://agentstack.voostack.com/s/alexbodner
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
