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, Temperature) 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 (%), Memory Usage (MB/%), and Temperature (C).
  • 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()

def format_metric(value, unit):
    return f"{value:.2f} {unit}" if value is not None else f"N/A {unit}"

print(f"Average Power: {format_metric(metrics['avg_power_w'], 'W')}")
print(f"Max Utilization: {format_metric(metrics['max_utilization_pct'], '%')}")
print(f"Max Temperature: {format_metric(metrics['max_temperature_c'], 'C')}")

# 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])).

  • Temperature: Uses psutil.sensors_temperatures() when the platform exposes CPU thermal sensors.

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.
  • Temperature: Reads on-die GPU temperature through NVML.

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.
  • Temperature: Parses NPU temperature from mobilint-cli status output when available.

📝 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
  "avg_temperature_c": 72.3,    // Average device temperature
  "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.1.0.tar.gz (19.4 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.1.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mblt_tracker-0.1.0.tar.gz
  • Upload date:
  • Size: 19.4 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.1.0.tar.gz
Algorithm Hash digest
SHA256 ad46d10fa7203f24664e3addaca5bae5b081f77f790c42ec8fced28747f6bd6c
MD5 0564bb72042d621b215725f3d158fe80
BLAKE2b-256 879eaf55f77cccfd139c5d4d9be0f5b1f8a4e4911797503d3dc54f208a0c43a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for mblt_tracker-0.1.0.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: mblt_tracker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a6964a1d7092f5b2b0416765e8999efb11ba0c1dbcba410aa0543a51eea8bb0
MD5 11af7392dea88d4c70faf9a25cb85ebf
BLAKE2b-256 1c13d5600de244f2f6cf5121682e3a2d584002b5ef027f79f73b52a1cd519e7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for mblt_tracker-0.1.0-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