Skip to main content

cjm-system-monitor-nvidia

Install

pip install cjm_system_monitor_nvidia

Project Structure

nbs/
├── meta.ipynb   # Metadata introspection for the NVIDIA monitor plugin used by cjm-ctl to generate the registration manifest
└── plugin.ipynb # Plugin implementation for NVIDIA GPU monitoring using nvitop

Total: 2 notebooks

Module Dependencies

graph LR
    meta["meta<br/>meta"]
    plugin["plugin<br/>plugin"]

No cross-module dependencies detected.

CLI Reference

No CLI commands found in this project.

Module Overview

Detailed documentation for each module in the project:

meta (meta.ipynb)

Metadata introspection for the NVIDIA monitor plugin used by cjm-ctl to generate the registration manifest

Import

from cjm_system_monitor_nvidia.meta import (
    get_plugin_metadata
)

Functions

def get_plugin_metadata() -> Dict[str, Any]:  # Plugin metadata for manifest generation
    """Return metadata required to register this plugin with the PluginManager."""
    # Fallback base path (current behavior for backward compatibility)
    base_path = os.path.dirname(os.path.dirname(sys.executable))
    
    # Use CJM config if available, else fallback to env-relative paths
    cjm_plugin_data_dir = os.environ.get("CJM_PLUGIN_DATA_DIR")
    
    # Plugin data directory
    plugin_name = "cjm-system-monitor-nvidia"
    if cjm_plugin_data_dir
    "Return metadata required to register this plugin with the PluginManager."

plugin (plugin.ipynb)

Plugin implementation for NVIDIA GPU monitoring using nvitop

Import

from cjm_system_monitor_nvidia.plugin import (
    NvidiaMonitorPlugin
)

Classes

class NvidiaMonitorPlugin:
    def __init__(self):
        """Initialize the NVIDIA monitor plugin."""
        self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
        self.config = {}

    @property
    def name(self) -> str:  # Tool identity, derived from the installed distribution (PILLAR 1c)
    "NVIDIA System Monitor using nvitop (a pure-telemetry ToolCapability)."
    
    def __init__(self):
            """Initialize the NVIDIA monitor plugin."""
            self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
            self.config = {}
    
        @property
        def name(self) -> str:  # Tool identity, derived from the installed distribution (PILLAR 1c)
        "Initialize the NVIDIA monitor plugin."
    
    def name(self) -> str:  # Tool identity, derived from the installed distribution (PILLAR 1c)
            """Get the tool name (the installed distribution name)."""
            from importlib.metadata import metadata, packages_distributions
            # `__package__` is None in a notebook/__main__ context, so guard the
            # derivation with the known package module name.
            pkg = __package__ or "cjm_system_monitor_nvidia"
            dist = (packages_distributions().get(pkg) or [pkg.replace("_", "-")])[0]
            return metadata(dist)["Name"]
    
        @property
        def version(self) -> str:  # Tool version
        "Get the tool name (the installed distribution name)."
    
    def version(self) -> str:  # Tool version
            """Get the tool version string."""
            from cjm_system_monitor_nvidia import __version__
            return __version__
    
        def initialize(
            self,
            config: Optional[Dict[str, Any]] = None  # Configuration dictionary
        ) -> None
        "Get the tool version string."
    
    def initialize(
            self,
            config: Optional[Dict[str, Any]] = None  # Configuration dictionary
        ) -> None
        "Initialize or reconfigure the plugin."
    
    def get_config_schema(self) -> Dict[str, Any]:  # JSON Schema
            """Return JSON Schema for configuration."""
            return {}  # No config needed for monitoring
    
        def get_current_config(self) -> Dict[str, Any]:  # Current config
        "Return JSON Schema for configuration."
    
    def get_current_config(self) -> Dict[str, Any]:  # Current config
            """Return current configuration."""
            return self.config
    
    
    
        def _get_gpu_info_internal(self) -> Dict[str, Any]:  # Raw GPU data
        "Return current configuration."
    
    def get_system_status(self) -> SystemStats:  # Current system telemetry
            """Collect host CPU/RAM + aggregated GPU stats as a typed SystemStats.
    
            Per-process GPU usage is exposed separately via `list_processes()`. This
            is the native-dispatch surface the substrate's `_get_global_stats` calls
            for resource-derived admission (`MonitorToolProtocol`).
            """
            # 1. Get Host CPU/RAM (psutil)
            vm = psutil.virtual_memory()
    
            # 2. Get GPU Data
            gpu_raw = self._get_gpu_info_internal()
    
            # 3. Aggregate GPU Stats for the Scheduler
            total_vram_free = 0
            total_vram_total = 0
            total_vram_used = 0
            max_load = 0
    
            if gpu_raw['available']
        "Collect host CPU/RAM + aggregated GPU stats as a typed SystemStats.

Per-process GPU usage is exposed separately via `list_processes()`. This
is the native-dispatch surface the substrate's `_get_global_stats` calls
for resource-derived admission (`MonitorToolProtocol`)."
    
    def list_processes(self) -> List[ProcessStats]:  # Per-process GPU usage
        "Per-process GPU memory usage as typed ProcessStats.

Sources the same nvitop/nvidia-smi enumeration `get_system_status` uses;
returns `[]` when there is no GPU or no per-process attribution available.
The substrate's GPU subtree attribution intersects these PIDs with the
worker's process tree (`attribute_gpu_to_worker_subtree`)."

Metadata

Release files for cjm-system-monitor-nvidia 0.0.24

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cjm-system-monitor-nvidia 0.0.24
File Size Uploaded Provenance
cjm_system_monitor_nvidia-0.0.24.tar.gz 10.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cjm-system-monitor-nvidia 0.0.24
File Interpreter ABI Platform
cjm_system_monitor_nvidia-0.0.24-py3-none-any.whl Python 3 none any Details

Total release size: 22.9 kB

Release files / cjm_system_monitor_nvidia-0.0.24.tar.gz

Download URL cjm_system_monitor_nvidia-0.0.24.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5a63de89df93f9a956fdd2ebddede95775244c271969640767b066a7ea6e6d2
BLAKE2b-256 checksum
How to use checksums
aae133850ffe748c1e82a5022ed04a8c5a1d61ee429c7aa4f42c96ab1089879c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / cjm_system_monitor_nvidia-0.0.24-py3-none-any.whl

Download URL cjm_system_monitor_nvidia-0.0.24-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf7312e39e251e8b00e855779385b674f9718437961414e6370bf727d9b184a8
BLAKE2b-256 checksum
How to use checksums
1ef861926b1e7571c68acfa1c6e616c5ba9ac11826bd31ea9507b36c0ec47374
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for cjm-system-monitor-nvidia 0.0.24

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page