agentleFS
ulab-uiuculab-uiuc/research-ledger/skills/gpu-manage/SKILL.md

gpu-manage

Skill2 starsChanged 7 months agoMITView on GitHub

Use BEFORE launching ANY GPU-using experiment, training, evaluation, or inference. Inspects available GPUs (via nvidia-smi or equivalent), shows their current memory, utilization, and running processes in a table, and EXPLICITLY waits for user confirmation on which GPU indices to use before any compute is spent. Output is shown inline AND appended to ./experiments/<name>-gpu-plan.md (or ./gpu-plan.md for ad-hoc) — append-only ledger of pre-flight checks. Hard rule: NO GPU work starts without a user-confirmed selection.

The file

Show its rules and text

We split this skill into the rules it gives an agent

14 rules. About 0 are common, 3 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    This skill is a HARD GATE: No downstream skill (exp-tracking, training scripts, anything that touches CUDA) launches GPU work without first …

    line 10
  2. Very specific:

    BEFORE invoking exp-tracking to launch experiments

    line 14
  3. Distinctive:

    BEFORE running training, fine-tuning, evaluation, or inference scripts that touch GPU

    line 15
  4. Distinctive:

    BEFORE allocating multi-GPU jobs (DDP, model-parallel, tensor-parallel, etc.)

    line 16
  5. Very specific:

    When re-checking GPU state mid-sweep (a new check appends a new Table N+1)

    line 17
  6. Distinctive:

    Every invocation produces TWO artifacts:

    line 27
  7. Very specific:

    Run nvidia-smi --query-gpu=index,name,memory.total,memory.used,memory.free,utilization.gpu --format=csv,noheader,nounits (or platform …

    line 38
  8. Very specific:

    After the user replies, append Table N+1 with your choice filled in (✓ selected, — skipped) and the resulting CUDA_VISIBLE_DEVICES=...

    line 42
  9. Very specific:

    Only then signal that downstream work (e.g., exp-tracking) may proceed with the agreed device list.

    line 43
  10. Very specific:

    If nvidia-smi fails or returns no devices (no GPU, no driver, remote machine without access): say so explicitly, append a one-row table …

    line 45
  11. Very specific:

    Detect: Run nvidia-smi. If it fails, surface the failure in a one-row table with status=n/a — no GPU detected and ask whether to proceed …

    line 77
  12. Very specific:

    WAIT: Do NOT proceed with any GPU work, do NOT issue any CUDA call, do NOT start exp-tracking, until the user replies with a specific …

    line 81
  13. Very specific:

    Confirm: When the user replies, append Table N+1 with your choice column filled in.

    line 82
  14. Very specific:

    Hand-off: Only after the confirmation table is appended may downstream tools launch jobs.

    line 83

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

GPU Management — Pre-Flight Selection

GPU allocation is a table written to a markdown file with EXPLICIT user confirmation, not a silent default. Before a single training step, evaluation, or inference call hits the GPU, this skill: (1) inspects what's actually available, (2) presents it as a table, (3) STOPS and waits for the user to confirm which GPUs to use, (4) records the selection in a markdown file as part of the experiment ledger.

This skill is a HARD GATE. No downstream skill (exp-tracking, training scripts, anything that touches CUDA) launches GPU work without first running through gpu-manage and getting explicit user confirmation on the device list.

When to Use

  • BEFORE invoking exp-tracking to launch experiments
  • BEFORE running training, fine-tuning, evaluation, or inference scripts that touch GPU
  • BEFORE allocating multi-GPU jobs (DDP, model-parallel, tensor-parallel, etc.)
  • When re-checking GPU state mid-sweep (a new check appends a new Table N+1)

When NOT to Use

  • Pure CPU work (no GPU involved)
  • Reading code or papers (no compute)
  • Debugging logic that doesn't touch a GPU

Output Contract — Both Inline AND File (Append-Only)

Every invocation produces TWO artifacts:

  1. Inline — the LATEST GPU table (Table N+1) with caption, in chat.
  2. File — append the new table at the END of ./experiments/<name>-gpu-plan.md (when associated with a sweep, use the same <name> as the design/tracking files). For ad-hoc checks not tied to a sweep, use ./gpu-plan.md at the project root. Use the Edit tool to APPEND, never the Write tool to overwrite. Earlier checks MUST stay intact.

The file is an append-only ledger of pre-flight checks: Table 1 (initial check before R1) → Table 2 (re-check before R3 after another user freed up GPU 2) → … → Table N. The trajectory shows which GPUs were available when each decision was made and which the user picked.

The Hard Gate (non-negotiable)

This skill MUST complete with EXPLICIT user confirmation before returning control. The flow:

  1. Run nvidia-smi --query-gpu=index,name,memory.total,memory.used,memory.free,utilization.gpu --format=csv,noheader,nounits (or platform equivalent) to detect GPUs. Also run nvidia-smi --query-compute-apps=gpu_uuid,pid,process_name,used_memory --format=csv,noheader,nounits (or nvidia-smi pmon) for per-process info.
  2. Build a table with the your choice column initially ? for every row.
  3. Append the table to the file and show it inline.
  4. STOP and ASK the user which GPUs to use. Do NOT pick devices yourself. Do NOT default to "all GPUs". Do NOT default to GPU 0. Do NOT proceed without an explicit answer.
  5. After the user replies, append Table N+1 with your choice filled in (✓ selected, — skipped) and the resulting CUDA_VISIBLE_DEVICES=... string in the caption update.
  6. Only then signal that downstream work (e.g., exp-tracking) may proceed with the agreed device list.

If nvidia-smi fails or returns no devices (no GPU, no driver, remote machine without access): say so explicitly, append a one-row table with status n/a — no GPU detected, and ASK whether to proceed CPU-only. Do not silently switch.

Caption Contract

  1. Pre-flight goal — what is about to run on the GPU(s)?
  2. Scope — single-node? multi-node? specific exp name?
  3. Acceptance — what counts as a usable GPU (free VRAM threshold, util threshold, etc.)?
  4. Update (for Table N where N>1) — what changed since the last check, AND the user's confirmed selection if applicable (e.g., "User selected GPU 0,2,4,5; CUDA_VISIBLE_DEVICES=0,2,4,5").

Format: **Table N.** <pre-flight goal> Scope: <scope>. Acceptance: <usable-GPU criterion>. Update: <delta and/or selection>.

Table Schema

| id | index | name | total VRAM | used VRAM | free VRAM | util% | processes | recommendation | your choice |
|----|-------|------|------------|-----------|-----------|-------|-----------|----------------|-------------|
| G0 | 0 | NVIDIA A100-SXM4-80GB | 80 GB | 2 GB | 78 GB | 0% | — | free | ? |
| G1 | 1 | NVIDIA A100-SXM4-80GB | 80 GB | 60 GB | 20 GB | 87% | [pid 12345 colleague-job](./logs/g1-other.log) | busy | ? |
  • id — stable id (G0..Gk).
  • index — the literal CUDA device index used in CUDA_VISIBLE_DEVICES.
  • name — GPU model from nvidia-smi.
  • total VRAM / used VRAM / free VRAM — in GB, two significant digits or rounded as appropriate.
  • util% — current utilization percent.
  • processes — list of [pid <pid> <command>](./path/to/log) for each process taking VRAM. Pid alone is not enough — surface the command so the user knows whose job it is. Empty: —.
  • recommendation — one of free (used <5% of VRAM, util ≈0%), partial (some headroom but other jobs running), busy (low headroom or high util), unknown.
  • your choice — ? until the user confirms; then ✓ or — (skipped) in the next appended table.
  • Empty cells: —. Never blank.

Interaction Flow

  1. Detect. Run nvidia-smi. If it fails, surface the failure in a one-row table with status=n/a — no GPU detected and ask whether to proceed CPU-only.
  2. Build Table 1. One row per detected GPU. Recommendation column populated. your choice column = ? for all rows.
  3. Append the file at ./experiments/<name>-gpu-plan.md (or ./gpu-plan.md).
  4. STOP and ASK. Show the table inline AND a clear question: "Which GPUs should this run use? Reply with indices (e.g., 0,2,4,5), all, or abort."
  5. WAIT. Do NOT proceed with any GPU work, do NOT issue any CUDA call, do NOT start exp-tracking, until the user replies with a specific selection.
  6. Confirm. When the user replies, append Table N+1 with your choice column filled in. The caption update names the selection and the resulting CUDA_VISIBLE_DEVICES=... string.
  7. Hand-off. Only after the confirmation table is appended may downstream tools launch jobs. Pass the selected indices forward (e.g., to exp-tracking).

Worked Example

The file ./experiments/lr-sweep-gpu-plan.md after one user confirmation contains both tables:

Table 1. Pre-flight GPU check before launching lr-sweep runs R1-R4 — Scope: single 8-GPU node gpu-host-01. Acceptance: ≥40 GB free VRAM and util ≤10% counts as free. Update: initial check.

idindexnametotal VRAMused VRAMfree VRAMutil%processesrecommendationyour choice
G00A100-SXM4-80GB80 GB2 GB78 GB0%—free?
G11A100-SXM4-80GB80 GB60 GB20 GB87%pid 12345 train.pybusy?
G22A100-SXM4-80GB80 GB1 GB79 GB0%—free?
G33A100-SXM4-80GB80 GB78 GB2 GB95%pid 67890 finetune.shbusy?
G44A100-SXM4-80GB80 GB1 GB79 GB0%—free?
G55A100-SXM4-80GB80 GB1 GB79 GB0%—free?
G66A100-SXM4-80GB80 GB1 GB79 GB0%—free?
G77A100-SXM4-80GB80 GB1 GB79 GB0%—free?

STOP — waiting for user to pick GPUs. Reply with indices (e.g., 0,2,4,5), all, or abort.

User: "use 0, 2, 4, 5"

Table 2. Pre-flight GPU check before launching lr-sweep runs R1-R4 — Scope: single 8-GPU node gpu-host-01. Acceptance: ≥40 GB free VRAM and util ≤10%. Update: user selected indices 0,2,4,5; CUDA_VISIBLE_DEVICES=0,2,4,5.

idindexnametotal VRAMused VRAMfree VRAMutil%processesrecommendationyour choice
G00A100-SXM4-80GB80 GB2 GB78 GB0%—free✓
G11A100-SXM4-80GB80 GB60 GB20 GB87%pid 12345 train.pybusy—
G22A100-SXM4-80GB80 GB1 GB79 GB0%—free✓
G33A100-SXM4-80GB80 GB78 GB2 GB95%pid 67890 finetune.shbusy—
G44A100-SXM4-80GB80 GB1 GB79 GB0%—free✓
G55A100-SXM4-80GB80 GB1 GB79 GB0%—free✓
G66A100-SXM4-80GB80 GB1 GB79 GB0%—free—
G77A100-SXM4-80GB80 GB1 GB79 GB0%—free—

In chat after the second update, show only Table 2. Now downstream skills (e.g., exp-tracking) may launch with CUDA_VISIBLE_DEVICES=0,2,4,5.

Common Mistakes

ThoughtReality
"I'll just default to GPU 0."NEVER pick GPUs without explicit user confirmation. Other people may be using GPU 0.
"All GPUs look free, I'll grab them all."Still ASK first. The user may want to leave headroom for someone else.
"nvidia-smi is taking time, I'll start the job and check after."No. Pre-flight comes BEFORE compute, not after. A wrong allocation costs hours and wrecks someone else's run.
"User said lr-sweep, obviously they want all 8 GPUs."The user said lr-sweep. They did NOT say which GPUs. Ask.
"I'll narrate which GPUs are free in chat"A narration is not a confirmation. Append the table, ask, wait.
"Skip the file for a quick check"The file is the audit trail of which GPUs you committed to using when. Append it.
"I'll overwrite Table 1 with the user's selection"Append Table 2. The trajectory IS the value (which GPUs were available, which were chosen).
"User said all — no need to record"Even all is an explicit confirmation that gets recorded in Table N+1 with all ✓.
"Process column with just pids is fine"Pids alone don't tell the user whose job is on the GPU. Include the command, link to a log if known.
"No nvidia-smi, must be a CPU-only machine — just run on CPU"If GPU work was intended and no GPU is detected, ASK before falling back to CPU.

Red Flags — STOP

ThoughtReality
"I'll start training with CUDA_VISIBLE_DEVICES=all and see what happens."STOP. Run gpu-manage first. Confirm with user.
"The user is in a hurry, I'll skip the GPU check."The fastest path is the safe path. A user-confirmed selection costs ~10 seconds. A wrong allocation costs hours.
"exp-tracking already started, I'll back-fill the GPU plan after."gpu-manage is a HARD gate BEFORE exp-tracking. No retroactive plans.
"GPU 1 is busy with someone's job — I'll just use the rest, no need to ask."ASK. The user may want to wait, may have priority, may want to coordinate with the other user.
"I'll skip writing the file since it's just a one-time check"Every check is recorded. Future you / another reader will want the audit trail.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.