Skip to content

fix(gpu): give nvidia-smi ProgramFiles under a minimal Windows env - #52

Open
sushiHex wants to merge 1 commit into
mainfrom
fix/nvidia-smi-env
Open

sushiHex wants to merge 1 commit into
mainfrom
fix/nvidia-smi-env

Conversation

@sushiHex

Copy link
Copy Markdown
Owner

Problem

A vram-mcp server started by an MCP client on Windows can't read free VRAM: nvidia-smi prints Failed to initialize NVML: Unknown Error and exits 255. warm then refuses with free_unknown (#47), and pressure reads unknown.

The cause is the environment. The MCP Python SDK's get_default_environment() passes only a short list of variables (APPDATA, HOMEDRIVE, HOMEPATH, LOCALAPPDATA, PATH, PATHEXT, SYSTEMROOT, TEMP, USERPROFILE, ...). nvidia-smi fails whenever both ProgramFiles and ProgramW6432 are unset. Bisected on the RTX 3090 desktop by adding each of the other variables to that minimal set in turn: only those two fix it. Adding WINDIR/PROGRAMDATA, or leaving out Hermes's Job object, does not, as Hermes confirmed separately. In-process NVML (pynvml) works under the same minimal environment.

Reported by the Hermes lane: its pinned server's first warm stopped with free_unknown, and the audit detail read nvidia-smi exited with status 255.

Change

When neither variable is set on Windows, gpu._run gives nvidia-smi ProgramFiles from the registry (HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\ProgramFilesDir). Otherwise, and off Windows, it inherits the server's environment unchanged.

Validation

  • python -m pytest tests/test_gpu.py -q: 19 passed, 4 of them new.
  • observe_gpu(0) in a child process with the SDK's minimal environment:
    • main: nvidia-smi exited with status 255
    • this branch: free_mb 10377

Workaround until this is deployed: add ProgramFiles to the server's env in the MCP client config.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V2ENBkHd7pik2TTJnhBHnh

On Windows, nvidia-smi prints "Failed to initialize NVML: Unknown Error"
and exits 255 when ProgramFiles and ProgramW6432 are both unset. MCP
clients start servers with a minimal inherited environment that lacks
both (the Python SDK's get_default_environment), so free VRAM read as
unknown and warm refused with free_unknown. In-process NVML works under
the same environment.

When neither variable is set, nvidia-smi now gets ProgramFiles from the
registry (HKLM ...\CurrentVersion\ProgramFilesDir). Otherwise it
inherits the server's environment unchanged.

Reported by codex:hermes-realtime.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V2ENBkHd7pik2TTJnhBHnh
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-30T08:12:17.567090Z e9f8e22 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant