[PR #398] [MERGED] Monitor: the GPU map finds an engine run through a launcher (its memory was drawn as other programs) #512

Closed
opened 2026-10-29 21:26:14 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/mw00/project-maya/pull/398
Author: @somnergy
Created: 10/22/2026
Status: ✅ Merged
Merged: 10/23/2026
Merged by: @mw00

Base: main ← Head: pr/gpu-map-container-pids


📝 Commits (1)

  • d37e50b Monitor: the GPU map finds an engine run through a launcher (its memory was drawn as other programs)

📊 Changes

3 files changed (+100 additions, -6 deletions)

View changed files

📝 serve/gpu_map.py (+19 -4)
📝 serve/server.py (+19 -2)
📝 serve/test_dashboard.py (+62 -0)

📄 Description

Problem

When the engine's command is a launcher that does not exec it (here a wrapper script that runs nsys launch), the Monitor's GPU map shows about 0.5-0.6 GB of "other programs" on every card, even though NVML lists only one process, the engine's.

Cause

gpu_map.view looks for the engine's NVML entry under the pid of the process the server started. With a launcher in between, that pid belongs to the launcher, and NVML lists the process the launcher started instead. So own is None, and the map falls back to the start's measurement. Then everything the card holds beyond that measurement is drawn as other programs: what the engine allocated after it, and the driver's reserve (NVML's used memory counts it, CUDA's total does not).

Fix

  • server.nvml_pids: when NVML lists processes but not the started one, it also looks for the processes the started one started in turn, at any depth (psutil). Without psutil it returns the pid alone.
  • gpu_map.view accepts a pid or a set of pids for the engine and for the vision encoder. Their NVML entries add up.
  • When NVML lists the started pid, nothing changes and the process tree is never walked. An engine that NVML lists under a pid the server can't see (a pid namespace it does not share) is still drawn from the start's measurement, as before.

How it was verified

Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, driver 615.71.09, Docker without --pid=host. Maya-L split over both cards.

  • Inside the container, NVML lists the engine under its pid in the container's namespace. With the engine started directly, main's map is already right (other programs 0.00), and the patch gives the identical map.
  • With the engine run through nsys launch from a wrapper script, main showed 0.5 GB of other programs per card.
  • I ran main's and the patched logic inside the container on the live NVML readings. To reproduce the launcher case, an ancestor of the engine was passed as the started process. Main's start measurement was estimated from the engine's load log.
card NVML used / engine's process main: other / rest patched: other / rest
0 72,982 / 72,360 MiB 0.57 / 7.82 GiB (start's measurement) 0.00 / 8.39 GiB (NVML)
1 72,980 / 72,358 MiB 0.57 / 6.74 GiB (start's measurement) 0.00 / 7.31 GiB (NVML)

Free memory is the same in both. With the engine started directly, main and the patch both give 0.00 / 8.39 and 0.00 / 7.31.

  • python -m unittest discover -s serve -p "test_*.py" -t .: 346 tests pass. The new tests cover:
    • an engine run through a launcher, alone, next to another program, and with the vision encoder;
    • an engine that NVML lists under a pid the server can't see;
    • nvml_pids on a real launcher and the grandchild it starts.

Not in this PR: wait_gpu_release also waits on the started pid only, so with a launcher it does not wait for the engine's memory to be freed.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/mw00/project-maya/pull/398 **Author:** [@somnergy](https://github.com/somnergy) **Created:** 10/22/2026 **Status:** ✅ Merged **Merged:** 10/23/2026 **Merged by:** [@mw00](https://github.com/mw00) **Base:** `main` ← **Head:** `pr/gpu-map-container-pids` --- ### 📝 Commits (1) - [`d37e50b`](https://github.com/mw00/project-maya/commit/d37e50bf3095e66a1ba77fd3c17b616646ae3bb1) Monitor: the GPU map finds an engine run through a launcher (its memory was drawn as other programs) ### 📊 Changes **3 files changed** (+100 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `serve/gpu_map.py` (+19 -4) 📝 `serve/server.py` (+19 -2) 📝 `serve/test_dashboard.py` (+62 -0) </details> ### 📄 Description ## Problem When the engine's command is a launcher that does not `exec` it (here a wrapper script that runs `nsys launch`), the Monitor's GPU map shows about 0.5-0.6 GB of "other programs" on every card, even though NVML lists only one process, the engine's. ## Cause `gpu_map.view` looks for the engine's NVML entry under the pid of the process the server started. With a launcher in between, that pid belongs to the launcher, and NVML lists the process the launcher started instead. So `own` is None, and the map falls back to the start's measurement. Then everything the card holds beyond that measurement is drawn as other programs: what the engine allocated after it, and the driver's reserve (NVML's used memory counts it, CUDA's total does not). ## Fix - `server.nvml_pids`: when NVML lists processes but not the started one, it also looks for the processes the started one started in turn, at any depth (psutil). Without psutil it returns the pid alone. - `gpu_map.view` accepts a pid or a set of pids for the engine and for the vision encoder. Their NVML entries add up. - When NVML lists the started pid, nothing changes and the process tree is never walked. An engine that NVML lists under a pid the server can't see (a pid namespace it does not share) is still drawn from the start's measurement, as before. ## How it was verified Hardware: 2x NVIDIA RTX PRO 5000 Blackwell 72 GB, driver 615.71.09, Docker without `--pid=host`. Maya-L split over both cards. - Inside the container, NVML lists the engine under its pid in the container's namespace. With the engine started directly, main's map is already right (other programs 0.00), and the patch gives the identical map. - With the engine run through `nsys launch` from a wrapper script, main showed 0.5 GB of other programs per card. - I ran main's and the patched logic inside the container on the live NVML readings. To reproduce the launcher case, an ancestor of the engine was passed as the started process. Main's start measurement was estimated from the engine's load log. | card | NVML used / engine's process | main: other / rest | patched: other / rest | |---|---|---|---| | 0 | 72,982 / 72,360 MiB | 0.57 / 7.82 GiB (start's measurement) | 0.00 / 8.39 GiB (NVML) | | 1 | 72,980 / 72,358 MiB | 0.57 / 6.74 GiB (start's measurement) | 0.00 / 7.31 GiB (NVML) | Free memory is the same in both. With the engine started directly, main and the patch both give 0.00 / 8.39 and 0.00 / 7.31. - `python -m unittest discover -s serve -p "test_*.py" -t .`: 346 tests pass. The new tests cover: - an engine run through a launcher, alone, next to another program, and with the vision encoder; - an engine that NVML lists under a pid the server can't see; - `nvml_pids` on a real launcher and the grandchild it starts. Not in this PR: `wait_gpu_release` also waits on the started pid only, so with a launcher it does not wait for the engine's memory to be freed. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 21:26:14 +07:00
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mw00/project-maya#512
No description provided.