Skip to main content
Glama

gpu_processes

Read-only

List running GPU compute processes with VRAM usage and card index. Returns empty when no workloads are active.

Instructions

List compute processes using the GPU (KFD PIDs) with their VRAM usage and card index. Returns an empty list when no compute workloads are running.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • async function gpuProcesses() — main handler for the gpu_processes tool. Calls rocm-smi --showpids --json, parses the JSON output, handles two possible shapes from different ROCm versions, extracts PID, process name, GPU count, VRAM bytes, SDMA bytes, and CU occupancy, and returns a list of running GPU compute processes.
    async function gpuProcesses() {
      const missing = requireRocmSmi();
      if (missing) return errorResult(missing);
    
      const r = await run(BIN.rocmSmi, ['--showpids', '--json']);
      // rocm-smi writes the JSON to stdout, and the "No JSON data to report"
      // warning to stderr. But some ROCm versions have been observed to swap
      // them, so try both streams before giving up.
      const data = parseRocmJson(r.stdout) || parseRocmJson(r.stderr);
    
      // Empty list = no KFD processes registered. Include raw stream snippets
      // in the note so the caller can tell "nothing is running" apart from
      // "rocm-smi returned an unexpected shape I couldn't parse".
      if (!data) {
        return textResult({
          timestamp: new Date().toISOString(),
          processes: [],
          note: 'No GPU compute processes currently running (or rocm-smi returned no parseable JSON).',
          diagnostic: {
            exit_code: r.code,
            stdout_snippet: (r.stdout || '').slice(0, 500),
            stderr_snippet: (r.stderr || '').slice(0, 500),
          },
        });
      }
    
      // rocm-smi --showpids --json emits one of two shapes depending on version:
      //   (a) {"system": {"PID19971": "python, 1, 1139888128, 0, unknown"}, ...}
      //   (b) {"system": {"19971": {"GPU use": "...", "VRAM": "...", ...}}, ...}
      // The CSV string in (a) is:
      //   "<process_name>, <gpu_count>, <vram_bytes>, <sdma_bytes>, <cu_occupancy>"
      const PID_KEY_RE = /^(?:PID)?(\d+)$/;
      const processes = [];
      for (const [k, v] of Object.entries(data)) {
        if (!v || typeof v !== 'object') continue;
        for (const [rawKey, info] of Object.entries(v)) {
          const m = rawKey.match(PID_KEY_RE);
          if (!m) continue;
          const pid = parseInt(m[1], 10);
          let entry;
          if (typeof info === 'string') {
            const parts = info.split(',').map((s) => s.trim());
            const [process_name, gpu_count, vram_bytes, sdma_bytes, cu_occupancy] = parts;
            entry = {
              pid,
              scope: k,
              process_name: process_name ?? null,
              gpu_count: gpu_count !== undefined ? parseInt(gpu_count, 10) : null,
              vram_bytes: vram_bytes !== undefined ? parseInt(vram_bytes, 10) : null,
              sdma_bytes: sdma_bytes !== undefined ? parseInt(sdma_bytes, 10) : null,
              cu_occupancy: cu_occupancy && cu_occupancy.toLowerCase() !== 'unknown'
                ? cu_occupancy
                : null,
            };
          } else if (info && typeof info === 'object') {
            entry = { pid, scope: k, ...info };
          } else {
            continue;
          }
          processes.push(entry);
        }
      }
    
      return textResult({
        timestamp: new Date().toISOString(),
        count: processes.length,
        processes,
      });
    }
  • server.js:369-373 (registration)
    Tool registration entry in the TOOLS array: declares name 'gpu_processes', description, annotations (read-only), and empty inputSchema.
      name: 'gpu_processes',
      description: 'List compute processes using the GPU (KFD PIDs) with their VRAM usage and card index. Returns an empty list when no compute workloads are running.',
      annotations: { title: 'List GPU processes', readOnlyHint: true, destructiveHint: false, openWorldHint: false },
      inputSchema: { type: 'object', properties: {}, additionalProperties: false },
    },
  • server.js:398-398 (registration)
    Handler mapping in HANDLERS object: 'gpu_processes' -> gpuProcesses function, used by the JSON-RPC dispatch in handle().
    gpu_processes: gpuProcesses,
Behavior4/5

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

Description adds behavioral context beyond annotations (e.g., returns empty list when no workloads) and confirms read-only nature. No contradictions.

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 succinct sentences covering purpose and behavior, front-loaded with the action, no unnecessary words.

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?

Without output schema, the description outlines return content (compute processes, VRAM, card index) and edge case. Could specify field details, but adequate for such a simple tool.

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

Parameters4/5

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

No parameters exist, so baseline 4 applies. Description need not add parameter info.

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 uses specific verb 'List' and resource 'compute processes using the GPU (KFD PIDs)', clearly distinguishing it from siblings like gpu_metrics or gpu_status.

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

Usage Guidelines2/5

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

No guidance on when to use this tool vs alternatives (e.g., gpu_watch, rocm_info), and no exclusions or prerequisites mentioned.

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