gpu-status
Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang.
Skill by yichiche
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/yichiche-gpu-status
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/gpu-status
What's inside
- Skill name
gpu-status- Description
- Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang. Joins rocm-smi to torch's CUDA index via PCI bus (the numberings differ!). Use when the user says '/gpu-status', '/gpu', asks which GPUs are free, or which CUDA_VISIBLE_DEVICES / device to launch on.
- License
- MIT
- Instructions
- 110 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (3)
- SKILL.md
- gpu_status.py
- pci_cuda_map.json
SKILL.md (first lines)
# GPU Status (which AMD GPUs are free + the CUDA index to use)
Report each AMD GPU's free/occupied state AND the **CUDA index** to actually pass to
SGLang. The user decides which GPUs to use; this skill only reports — it does **not**
launch anything or set any environment variable.
## Two facts this skill exists to handle (do not forget)
1. **SGLang on ROCm uses `CUDA_VISIBLE_DEVICES`, never `HIP_VISIBLE_DEVICES`.**
It selects GPUs via `CUDA_VISIBLE_DEVICES` + `--base-gpu-id`. Setting
`HIP_VISIBLE_DEVICES` does nothing useful and can double-remap you onto a busy
card. Never tell the user to set `HIP_VISIBLE_DEVICES`, and never set both.
2. **rocm-smi's GPU index ≠ CUDA/torch index.** They are permuted on this hardware
(current map: CUDA 0→rocm 3, 1→0, 2→2, 3→1, 4→7, 5→4, 6→6, 7→5). The only reliable
bridge is the **PCI bus id**. Never assume `rocm-smi GPU N == CUDA N`. This map is
cached (see below) and only changes on reboot.
The script handles both: it joins `rocm-smi --json` (VRAM/bus per physical GPU) to the
CUDA index → PCI bus map on the PCI bus, so the `CUDA` column it prints is copy-paste
ready as a `CUDA_VISIBLE_DEVICES` value.
## The CUDA↔PCI map is CACHED — normally no torch probe (this is the fast path)
The CUDA↔PCI mapping only changes when the **host reboots**, and probing torch is slow
and frequently impossible here (the host and freshly-started/empty containers report
`No HIP GPUs`; only a GPU-healthy container can probe). So the map is **cached** in
`pci_cuda_map.json` next to the script, keyed by the kernel **boot_id**:
- **Normal run (boot_id unchanged):** the script reuses the cached map and only runs
`rocm-smi` to refresh **current GPU usage** (VRAM/util). No torch probe. Fast. The
footer prints `(CUDA<->PCI map source: cache; ...)`. **Just run it — do not re-derive
the mapping.**
- **After a reboot (boot_id changed) — must re-confirm:** the script detects this and
tries a fresh torch probe; if it succeeds it rewrites the cache automatically. If
torch can't probe where you ran it, it prints a loud `WARNING: reboot detected ...
CUDA indices may be WRONG` and falls back to the stale map. In that case **re-seed
the map** (see below) before trusting the CUDA column.
**To re-seed / re-confirm the map after a reboot:** run on a GPU-healthy container
(one that has loaded a model / can `import torch` and see all GPUs):
```bash
docker exec <healthy-container> python3 ~/.claude/skills/gpu-status/gpu_status.py --remap
```
`--remap` forces a torch probe and rewrites `pci_cuda_map.json` with the new boot_id.
(The home dir is mounted into the containers, so the cache it writes is shared back to
the host and other containers.)
## How to run
```bash
python3 ~/.claude/skills/gpu-status/gpu_status.py
```
Normal runs work **anywhere** (host included) thanks to the cache — torch is not
needed unless re-seeding after a reboot.
Options:
- `--threshold G` — a GPU counts as FREE when used VRAM < G GiB (default `5`).
- `--json` — emit `{gpus: [...], free_cuda_indices: [...], map_source: ...}`.
- `--remap` — force a fresh torch probe and rewrite the cache (use after a reboot, on
a GPU-healthy container).
## Output
```
CUDA rocm-smi PCI Bus Status VRAM used GPU%
0 3 0000:75:00.0 🔴OCCUPIED 220.0/288 GiB 0%
2 2 0000:65:00.0 🟢FREE 0.3/288 GiB 0%
...
Free CUDA indices: [2, 6, 7]
==> CUDA_VISIBLE_DEVICES=2,6,7
e.g. CUDA_VISIBLE_DEVICES=2,6 python -m sglang.launch_server --tp 2 ...
```
## What to tell the user
1. Run the script and show the table.
2. Report the **CUDA indices** that are free (the `CUDA` column), not the rocm-smi
indices. The ready-to-use line is `CUDA_VISIBLE_DEVICES=<free cuda indices>`.
3. Let the user pick how many / which. To launch on N of them, take the first N free
CUDA indices: `CUDA_VISIBLE_DEVICES=<picked> python -m sglang.launch_server --tp N ...`.
4. Do not choose for them or run any workload.
To verify a chosen launch lands on idle cards, the printed bus should match a FREE
row in the table:
```bash
CUDA_VISIBLE_DEVICES=2,6 python3 -c "import torch; [print(i, torch.cuda.get_device_properties(i).pci_bus_id) for i in range(torch.cuda.device_count())]"
```
## Notes
- Free/occupied is judged by **used VRAM** (`--threshold`), not GPU%: a card can sit
at 0% util while still holding a model in VRAM (it's still in use).
- The CUDA column comes from the **cache** on normal runs (see the caching section).
`map_source` in the footer / JSON tells you which map was used: `cache` (normal),
`probe (cache rewritten)` (re-seeded), or `STALE cache` (reboot, re-confirm needed).
- If there's no cache **and** torch can't be probed, the `CUDA` column shows `?` and a
warning is printed — do NOT fall back to the rocm-smi index, it is not a safe
substitute; re-seed with `--remap` on a GPU-healthy container.
- `rocm-smi` (at `/opt/rocm/bin`) is always required. `torch` is required **only** for
`--remap` / first-time seeding, not for normal cached runs.
- **Never export an *empty* `CUDA_VISIBLE_DEVICES`/`HIP_VISIBLE_DEVICES`/`ROCR_VISIBLE_DEVICES`.**
An empty value means *no GPUs visible* — torch then reports `device_count 0` and
servers fail with "No HIP GPUs". To use the free cards, pass the actual indices
(e.g. `HIP_VISIBLE_DEVICES=6,7`); to see all, leave the var **unset**, don't set `=`.
On ROCm, `HIP_VISIBLE_DEVICES` indexes the **same enumeration as the CUDA column**
here, so the free CUDA indices double as the HIP indices for launching.From yichiche/agent-box, MIT.
More from yichiche/agent-box
- 0.600score
gfx950-asm-development
yichiche
Develop, validate, and tune hand-written AMD gfx950 assembly kernels, with rocprof profiling.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
commit-push
yichiche
Commit (if needed) and push to the user's fork, with repo-aware remote selection and user confirmation before push.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
implement-kernel
yichiche
Implement a kernel optimization for SGLang on MI355/ROCm.
SkillAFreshness: A★ 2Claude Code +9 - 0.595score
generate-profile
yichiche
Generate an e2e profiling trace of an SGLang server run.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
abox-live
yichiche
Monitor Claude agents running inside your containers, from the host or phone — the single entry point (absorbed the old `abox`).
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
pr-conflict-fix
yichiche
Resolve a conflicting GitHub PR inside a throwaway container built from an image you name.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
commit-push-pr
yichiche
Commit, push, and create a PR in one flow — checks state at each stage, confirms push target, collects accuracy/benchmark data, drafts PR in HackMD format for…
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
compare-kernels
yichiche
Compare kernel categories and timings between two trace analysis Excel files.
SkillAFreshness: A★ 2Claude Code +9 - 0.589score
ci-analysis
yichiche
Analyze GitHub Actions CI failures for a pull request: trace root-cause jobs vs fast-fail cascades (check-pr-test-health), fetch job logs with gh, attribute…
SkillAFreshness: A★ 2Claude Code +9 - 0.585score
pr-ci-watch
yichiche
Watch a list of sgl-project/sglang PRs on two cadences (daily, or high-priority every 2h) and babysit them — re-run red NVIDIA CI only after /ci-analysis…
SkillAFreshness: A★ 2Claude Code +9 - 0.557score
debug-kernel-crash
yichiche
Debug GPU kernel crashes in SGLang (CUDA and ROCm) using @debug_kernel_api logging — illegal memory access, device assert, NaN/Inf, wrong shapes.
SkillBFreshness: B★ 2Claude Code +9 - 0.557score
add-jit-kernel
yichiche
Step-by-step guide for adding a lightweight JIT kernel to SGLang — CUDA path via python/sglang/kernels/jit, ROCm/MI355 path via Triton or aiter.
SkillBFreshness: B★ 2Claude Code +9
Signals
- Stars
- 2
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 1, 2026 (27 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/yichiche/agent-box
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from yichiche
- 0.600score
gfx950-asm-development
yichiche
Develop, validate, and tune hand-written AMD gfx950 assembly kernels, with rocprof profiling.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
commit-push
yichiche
Commit (if needed) and push to the user's fork, with repo-aware remote selection and user confirmation before push.
SkillAFreshness: A★ 2Claude Code +9 - 0.598score
implement-kernel
yichiche
Implement a kernel optimization for SGLang on MI355/ROCm.
SkillAFreshness: A★ 2Claude Code +9 - 0.595score
generate-profile
yichiche
Generate an e2e profiling trace of an SGLang server run.
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
abox-live
yichiche
Monitor Claude agents running inside your containers, from the host or phone — the single entry point (absorbed the old `abox`).
SkillAFreshness: A★ 2Claude Code +9 - 0.594score
pr-conflict-fix
yichiche
Resolve a conflicting GitHub PR inside a throwaway container built from an image you name.
SkillAFreshness: A★ 2Claude Code +9
Cite this page
gpu-status skill. Agent Mart. https://agentmart.dev/skills/yichiche-gpu-status (last updated 2026-10-24)