gpu-to-containers
Maps GPUs to Docker/Podman/containerd workloads by joining driver PIDs to cgroups.
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-to-containers
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
Use cases: devops
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-to-containers
What's inside
- Skill name
gpu-to-containers- Description
- Maps GPUs to Docker/Podman/containerd workloads by joining driver PIDs to cgroups. Use when the user asks which container uses which GPU, who is on GPU 0/1, GPU occupancy vs containers, or after rocm-smi/nvidia-smi shows busy cards and they need the owning workload name.
- License
- MIT
- Instructions
- 138 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (2)
- SKILL.md
- gpu_vram_owner.py · scripts/
SKILL.md (first lines)
# GPU → container mapping
Answer **which container (or host process)** is using **which GPU** by: (1) list
PIDs per GPU from the driver, (2) resolve each PID to a container id/name from
`/proc/<pid>/cgroup` (and optional `docker inspect` / `crictl`).
**Privilege:** Reading other users' `/proc/<pid>/cgroup` may require root or the
same user as the workload. If resolution fails, say so and suggest `sudo` or
running from the host as root.
## AMD ROCm (MI300 / MI355 / generic KFD)
1. **PIDs per GPU** (KFD compute clients):
```bash
rocm-smi --showpids
# more detail when supported:
rocm-smi --showpids details
```
To query **which GPUs a PID uses**:
```bash
rocm-smi --showpidgpus <PID>
```
`rocm-smi` **device index** here is the same ordering as concise info
(`rocm-smi` without args). It is **not** the same as PyTorch `CUDA_VISIBLE_DEVICES`
index on permuted hosts — if the user needs the torch index, use the personal
skill `gpu-status` (`~/.claude/skills/gpu-status/SKILL.md`) separately.
**Important:** KFD’s `GPU(s)` column in `--showpids` is often a **process-local**
logical index (e.g. after `CUDA_VISIBLE_DEVICES` remapping), **not** the same as
physical `GPU[n]` / `rocm-smi` Device rows. Do **not** use it alone to answer
“which **physical** GPU is which container”.
### Per **physical** GPU: VRAM / GPU% → main container (preferred on ROCm 7.x)
Use **`amd-smi process`** (JSON) — it returns **per GPU id 0…N-1** a `process_list`
with `pid` and `mem_usage` in bytes. For each GPU, take the PID with **maximum**
`mem_usage` on that GPU, then resolve the PID to a Docker name via cgroup (same
as above). Combine with **`rocm-smi`** concise output for **VRAM%** and **GPU%**
on the same host snapshot.
```bash
python3 ~/.cursor/skills/gpu-to-containers/scripts/gpu_vram_owner.py
```
Requires `amd-smi` on PATH (ROCm 7.x ships it) and `docker` for name resolution.
**PID → container (cgroup)** — for each PID from `amd-smi` or `--showpids`, run:
```bash
PID=12345
tr '\0' '\n' < "/proc/$PID/cgroup" 2>/dev/null || cat "/proc/$PID/cgroup"
```
Interpretation:
- **Docker Engine**: cgroup path often contains `docker-` + **64-char** container id
(e.g. `.../docker-<id>.scope`). Match with:
```bash
docker ps --no-trunc --format '{{.ID}}\t{{.Names}}'
```
- **containerd / Kubernetes**: look for `cri-containerd-` + id, or `kubepods`
slice; resolve pod/container with:
```bash
sudo crictl ps -a
# or kubectl get pods -A -o wide # then correlate node-local PIDs with admin tooling
```
- **Podman**: paths may contain `libpod-` and scope names with the container id.
3. **If `--showpids` is empty but VRAM is high** — the process may have exited
while VRAM is not reclaimed yet, or the query needs root / a newer `rocm-smi`.
Cross-check with `rocm-smi --showmeminfo vram` and retry after workloads settle.
## NVIDIA
1. **PIDs per GPU:**
```bash
nvidia-smi --query-compute-apps=gpu_uuid,gpu_bus_id,pid,process_name,used_memory --format=csv
nvidia-smi pmon -c 1
```
2. Same **PID → cgroup → `docker ps` / `crictl`** flow as above.
## One-shot host helper (bash)
Run on the **host** (not inside a container), adjust `sudo` if needed:
```bash
pid_container_hint() {
local pid="$1"
[[ -z "$pid" || ! -r "/proc/$pid/cgroup" ]] && { echo "$pid (cgroup unreadable)"; return; }
local line
line=$(tr '\0' '\n' < "/proc/$pid/cgroup" 2>/dev/null | paste -sd' ')
local id=""
if [[ "$line" =~ docker-([a-f0-9]{64}) ]]; then id="${BASH_REMATCH[1]}"; fi
if [[ -z "$id" && "$line" =~ cri-containerd-([a-f0-9]+) ]]; then id="${BASH_REMATCH[1]}"; fi
if [[ -n "$id" ]]; then
docker ps --no-trunc --filter "id=$id" --format '{{.Names}}\t{{.Image}}\t{{.ID}}' 2>/dev/null \
|| echo "id=$id (docker CLI unavailable or not Docker)"
else
echo "$pid $line"
fi
}
echo "=== rocm-smi PIDs ==="
rocm-smi --showpids 2>/dev/null || true
echo "=== nvidia-smi PIDs ==="
nvidia-smi --query-compute-apps=gpu_bus_id,pid,process_name --format=csv 2>/dev/null || true
echo "=== cgroup hints for ROCm PIDs (first column of KFD table rows) ==="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.598score
gpu-status
yichiche
Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang.
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
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
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
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
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
Signals
- Stars
- 2
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 17, 2026 (3 months 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
implement-kernel
yichiche
Implement a kernel optimization for SGLang on MI355/ROCm.
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
gpu-status
yichiche
Show which AMD GPUs are free and the exact CUDA_VISIBLE_DEVICES to use for SGLang.
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
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
Cite this page
gpu-to-containers skill. Agent Mart. https://agentmart.dev/skills/yichiche-gpu-to-containers (last updated 2026-10-24)