A Python library to track device usage, such as Mobilint NPU, NVIDIA GPU, Intel CPU, ...
Project description
Mobilint Device Tracker
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
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
--privilegedor 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-cliis 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:
- Install dev dependencies:
pip install -e ".[dev]" - Run tests:
pytest tests/
📄 License
This project is licensed under the BSD-3-Clause License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddedc1bfefe38870564d3edd8cc47f4b9c237cae85947b6399b20912d4592836
|
|
| MD5 |
87e4fa2639467b33793c7a75ab14929c
|
|
| BLAKE2b-256 |
30bebbc0e2ccf2bc2dcfbf2140c119c92d4791565d3849578c289539fa413f0e
|
Provenance
The following attestation bundles were made for mblt_tracker-0.0.2.tar.gz:
Publisher:
publish.yml on mobilint/mblt-tracker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mblt_tracker-0.0.2.tar.gz -
Subject digest:
ddedc1bfefe38870564d3edd8cc47f4b9c237cae85947b6399b20912d4592836 - Sigstore transparency entry: 1303874310
- Sigstore integration time:
-
Permalink:
mobilint/mblt-tracker@3805024abe0a61ae505859ba42aa22b87174478c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/mobilint
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3805024abe0a61ae505859ba42aa22b87174478c -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9ccbaac6fbbbf3683bd45d21b61a20aadcd17dff18c03ade4aa9f9c5d879887
|
|
| MD5 |
c02d053b239d60f38ef31ec60b9d206a
|
|
| BLAKE2b-256 |
f9cd1fb31330ce8b9c96e391c6eb2ce8046ec9f95d9c6a2748035fdcbd876fc9
|
Provenance
The following attestation bundles were made for mblt_tracker-0.0.2-py3-none-any.whl:
Publisher:
publish.yml on mobilint/mblt-tracker
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mblt_tracker-0.0.2-py3-none-any.whl -
Subject digest:
b9ccbaac6fbbbf3683bd45d21b61a20aadcd17dff18c03ade4aa9f9c5d879887 - Sigstore transparency entry: 1303874403
- Sigstore integration time:
-
Permalink:
mobilint/mblt-tracker@3805024abe0a61ae505859ba42aa22b87174478c -
Branch / Tag:
refs/tags/v0.0.2 - Owner: https://github.com/mobilint
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3805024abe0a61ae505859ba42aa22b87174478c -
Trigger Event:
release
-
Statement type: