Skip to main content

A Python library to track device usage, such as Mobilint NPU, NVIDIA GPU, Intel CPU, ...

Project description

Mobilint Device Tracker

Mobilint Logo

A lightweight Python library for tracking hardware metrics (Power, Utilization, Memory) across CPU, GPU, and NPU.

Overview

mblt-tracker is designed to help developers and researchers measure hardware performance with fair and consistent criteria. It provides a unified interface to poll metrics in the background while your code runs, producing both summarized statistics and detailed time-series traces.

✨ Key Features

  • Multi-Backend Support: Unified interface for Intel CPU, NVIDIA GPU, and Mobilint NPU.
  • Background Tracking: Uses a background scheduler to poll metrics without blocking your main execution.
  • Comprehensive Metrics: Capture Power (Watts), Utilization (%), and Memory Usage (MB/%).
  • Statistical Summaries: Automatically calculates averages, peaks (max), and p99 values.
  • Time-Series Traces: Export raw data for custom plotting and analysis.
  • Lightweight: Minimal overhead, designed for production and research environments.

🚀 Installation

PyPI - Version PyPI Downloads PyPI - Python Version

pip install mblt-tracker

For the latest features, install directly from source:

git clone https://github.com/mobilint/mblt-tracker.git
cd mblt-tracker
pip install -e .

📖 Quick Start Guide

The typical workflow involves initializing a tracker, starting it before your target workload, and stopping it after.

from mblt_tracker import CPUDeviceTracker # or GPUDeviceTracker, NPUDeviceTracker

# 1. Initialize with a polling interval (seconds)
tracker = CPUDeviceTracker(interval=0.1)

# 2. Start tracking (best to run after warm-up)
tracker.start()

# --- Your workload starts here ---
# e.g., model.inference(data)
# --- Your workload ends here ---

# 3. Stop tracking
tracker.stop()

# 4. Access results
metrics = tracker.get_metric()
print(f"Average Power: {metrics['avg_power_w']:.2f} W")
print(f"Max Utilization: {metrics['max_utilization_pct']:.2f} %")

# 5. Export time-series trace (list of (timestamp, power_w))
trace = tracker.get_trace()

📊 Metrics Coverage

Metric Intel CPU NVIDIA GPU Mobilint NPU
Power (W) ✅ (RAPL) ✅ (NVML) ✅ (mobilint-cli)
Utilization (%) ✅ (psutil) ✅ (NVML) ✅ (mobilint-cli)
Memory (MB/%) ✅ (psutil) ✅ (NVML) ✅ (mobilint-cli)
Per-Device Stats ✅ (Sockets) ✅ (GPU Indices) ❌ (Global/Total)

🛠️ Hardware Specifics

Intel CPU

Uses pyRAPL for power measurements and psutil for utilization/memory.

  • Permission: Requires read access to Intel RAPL sysfs.

    sudo chmod -R a+r /sys/class/powercap/intel-rapl/
    
  • Docker: Run containers with --privileged or mount the powercap directory.

  • Features: Tracks total system CPU usage or specific indices (e.g., CPUDeviceTracker(cpu_id=[0, 1])).

NVIDIA GPU

Uses NVML (via nvidia-ml-py) for high-fidelity hardware monitoring.

  • Features: Tracks total system GPU usage or specific indices (e.g., GPUDeviceTracker(gpu_id=[0, 1])).
  • Dependencies: Requires NVIDIA Drivers and NVML library installed.

Mobilint NPU

Polls the mobilint-cli status command.

  • Platform: Currently supports Linux only.
  • Requirement: Ensure Mobilint Utility Tool is installed and mobilint-cli is in your PATH.
  • NPU Power: Distinguishes between NPU-specific power and total system power.

📝 Metric Output Format

Calling get_metric() returns a dictionary with the following standard keys (where applicable):

{
  "avg_power_w": 25.4,          // Average total power in Watts
  "max_power_w": 45.2,          // Peak power observed
  "p99_power_w": 40.1,          // 99th percentile power
  "avg_utilization_pct": 78.5,  // Average device utilization
  "max_utilization_pct": 95.0,  // Peak device utilization
  "avg_memory_used_mb": 2048.0, // Average memory usage
  "total_memory_mb": 8192.0,    // Total available memory
  "samples": 100                // Number of data points collected
}

Note: Some trackers provide additional keys like cpu or gpu for per-socket/per-device breakdown.


🤝 Contributing

We welcome contributions! To set up for development:

  1. Install dev dependencies: pip install -e ".[dev]"
  2. Run tests: pytest tests/

📄 License

This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.


Developed with ❤️ by Mobilint Inc.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mblt_tracker-0.0.2.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mblt_tracker-0.0.2-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file mblt_tracker-0.0.2.tar.gz.

File metadata

  • Download URL: mblt_tracker-0.0.2.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mblt_tracker-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ddedc1bfefe38870564d3edd8cc47f4b9c237cae85947b6399b20912d4592836
MD5 87e4fa2639467b33793c7a75ab14929c
BLAKE2b-256 30bebbc0e2ccf2bc2dcfbf2140c119c92d4791565d3849578c289539fa413f0e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mblt_tracker-0.0.2.tar.gz:

Publisher: publish.yml on mobilint/mblt-tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mblt_tracker-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mblt_tracker-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mblt_tracker-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b9ccbaac6fbbbf3683bd45d21b61a20aadcd17dff18c03ade4aa9f9c5d879887
MD5 c02d053b239d60f38ef31ec60b9d206a
BLAKE2b-256 f9cd1fb31330ce8b9c96e391c6eb2ce8046ec9f95d9c6a2748035fdcbd876fc9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mblt_tracker-0.0.2-py3-none-any.whl:

Publisher: publish.yml on mobilint/mblt-tracker

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page