Skip to main content
Glama

gpu_watch

Read-only

Sample GPU status over a fixed interval to capture utilization, temperature, power, and VRAM usage, returning per-card statistics to assess training stability.

Instructions

Take N snapshots of gpu_status at a fixed interval and return both the raw frames and per-card min/max/avg statistics for utilization, temperature, power, and VRAM usage. Useful for answering “is this training run stable?”. Default: 5 samples at 1000ms intervals.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
samplesNoNumber of samples to take (2–60). Default: 5.
interval_msNoMilliseconds between samples (100–10000). Default: 1000.

Implementation Reference

  • Main handler function for the gpu_watch tool. Takes N snapshots of GPU status at fixed intervals, computes per-card min/max/avg statistics for utilization, temperature, power, and VRAM usage, and returns the raw frames plus aggregated stats.
    async function gpuWatch(args) {
      const missing = requireRocmSmi();
      if (missing) return errorResult(missing);
    
      const samples = Math.max(2, Math.min(60, Math.floor(args.samples ?? 5)));
      const intervalMs = Math.max(100, Math.min(10000, Math.floor(args.interval_ms ?? 1000)));
    
      const snapshots = [];
      for (let i = 0; i < samples; i++) {
        if (i > 0) await new Promise((r) => setTimeout(r, intervalMs));
        const r = await run(BIN.rocmSmi, ['-a', '--json']);
        const data = parseRocmJson(r.stdout);
        const vram = parseRocmJson((await run(BIN.rocmSmi, ['--showmeminfo', 'vram', '--json'])).stdout) || {};
        const frame = { timestamp: new Date().toISOString(), cards: [] };
        if (data) {
          for (const k of cardKeys(data)) {
            const c = data[k];
            const v = vram[k] || {};
            frame.cards.push({
              card: k,
              utilization_percent: numOrNull(c['GPU use (%)']),
              vram_used_bytes: numOrNull(v['VRAM Total Used Memory (B)']),
              temp_edge_c: numOrNull(c['Temperature (Sensor edge) (C)']),
              power_avg_w: numOrNull(c['Average Graphics Package Power (W)']),
              fan_rpm: numOrNull(c['Fan RPM']),
            });
          }
        }
        snapshots.push(frame);
      }
    
      // Compute per-card deltas (min/max/avg of utilization and temp) as a
      // convenience so the caller doesn't have to aggregate themselves.
      const summary = {};
      for (const frame of snapshots) {
        for (const c of frame.cards) {
          if (!summary[c.card]) {
            summary[c.card] = { utilization: [], temp: [], power: [], vram: [] };
          }
          if (c.utilization_percent !== null) summary[c.card].utilization.push(c.utilization_percent);
          if (c.temp_edge_c !== null) summary[c.card].temp.push(c.temp_edge_c);
          if (c.power_avg_w !== null) summary[c.card].power.push(c.power_avg_w);
          if (c.vram_used_bytes !== null) summary[c.card].vram.push(c.vram_used_bytes);
        }
      }
      function stats(arr) {
        if (!arr.length) return null;
        const min = Math.min(...arr);
        const max = Math.max(...arr);
        const avg = arr.reduce((a, b) => a + b, 0) / arr.length;
        return { min, max, avg: Math.round(avg * 100) / 100, samples: arr.length };
      }
      const perCard = {};
      for (const [card, s] of Object.entries(summary)) {
        perCard[card] = {
          utilization_percent: stats(s.utilization),
          temp_edge_c: stats(s.temp),
          power_avg_w: stats(s.power),
          vram_used_bytes: stats(s.vram),
        };
      }
    
      return textResult({
        samples,
        interval_ms: intervalMs,
        total_duration_ms: intervalMs * (samples - 1),
        snapshots,
        per_card_stats: perCard,
      });
    }
  • Tool registration entry for gpu_watch with name, description, annotations, and inputSchema (samples: min 2 max 60 default 5, interval_ms: min 100 max 10000 default 1000).
    {
      name: 'gpu_watch',
      description: 'Take N snapshots of gpu_status at a fixed interval and return both the raw frames and per-card min/max/avg statistics for utilization, temperature, power, and VRAM usage. Useful for answering “is this training run stable?”. Default: 5 samples at 1000ms intervals.',
      annotations: { title: 'Watch GPU over time', readOnlyHint: true, destructiveHint: false, openWorldHint: false },
      inputSchema: {
        type: 'object',
        properties: {
          samples: { type: 'integer', minimum: 2, maximum: 60, description: 'Number of samples to take (2–60). Default: 5.' },
          interval_ms: { type: 'integer', minimum: 100, maximum: 10000, description: 'Milliseconds between samples (100–10000). Default: 1000.' },
        },
        additionalProperties: false,
      },
    },
  • server.js:395-401 (registration)
    HANDLERS mapping that routes the 'gpu_watch' tool name to the gpuWatch function.
    const HANDLERS = {
      gpu_status: gpuStatus,
      gpu_metrics: gpuMetrics,
      gpu_processes: gpuProcesses,
      gpu_watch: gpuWatch,
      rocm_info: rocmInfo,
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already declare readOnlyHint=true, so no contradiction. Description adds that it returns raw and aggregated data, but omits that the tool blocks for the total sampling duration, which is important for agent planning.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no fluff: purpose, use case, and defaults are front-loaded efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given 2 params with full schema coverage, no output schema, and sibling tools, the description adequately explains input, output (raw and stats), and use case. Lacks return structure details but acceptable.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear parameter descriptions including defaults. The tool description does not add meaning beyond what the schema already provides, so baseline 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it takes N snapshots of gpu_status at intervals and returns raw frames plus per-card statistics, distinguishing it from siblings like gpu_status (single snapshot) and gpu_metrics (single metrics).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It provides a specific use case ('is this training run stable?') and default parameters, implying when to use it. However, it does not explicitly mention alternatives or when not to use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/LukeLamb/claude-rocm-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server