Metadata-Version: 2.5
Name: rampgate-nvml
Version: 0.1.0
Summary: NVIDIA GPU probe for rampgate (NVML), with process-to-container mapping.
Project-URL: Homepage, https://github.com/KebanFiru/rampgate
Project-URL: Documentation, https://kebanfiru.github.io/rampgate/
Project-URL: Source, https://github.com/KebanFiru/rampgate
Project-URL: Changelog, https://github.com/KebanFiru/rampgate/blob/main/packages/rampgate-nvml/CHANGELOG.md
Project-URL: Issues, https://github.com/KebanFiru/rampgate/issues
Author: Hakan Bağıç
License-Expression: Apache-2.0
License-File: LICENSE
License-File: NOTICE
Keywords: gpu,nvidia,nvml,rampgate,scheduler
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: System :: Distributed Computing
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: nvidia-ml-py>=12.535
Requires-Dist: rampgate<0.2,>=0.1
Description-Content-Type: text/markdown

# rampgate-nvml

NVIDIA GPU probe for rampgate (NVML), with process-to-container mapping.

Part of the [rampgate](https://github.com/KebanFiru/rampgate) monorepo.

```python
from rampgate_nvml import NvmlProbe, pid_to_container_id

with NvmlProbe({0: "gpu0"}, unit="MiB") as probe:
    for device in probe.devices():            # capacity: total GPU memory
        engine.add_device(device)
    observed, processes = probe.sample(t)     # DeviceObserved per GPU, ProcessUsage per process
    for p in processes:
        container = pid_to_container_id(p.pid)  # via /proc/<pid>/cgroup; None outside a container
```

- `DeviceObserved.used_total` is NVML's `used`, which includes the driver's own share and every process, managed or not. rampgate treats what it cannot attribute to a managed job as foreign usage.
- `pid_to_container_id` understands cgroup v1 and v2 paths of docker (systemd and cgroupfs drivers), containerd, CRI-O and podman. Paths relative to a private cgroup namespace (`0::/../docker-<id>.scope`) work too.
- **Host PID namespace required.** NVML lists processes by host pid, so a probe running in a container needs `docker run --pid=host` (and `--gpus all`).
