Skip to main content

A tool for granular energy measurement, empowering digital sustainability in machine learning and AI workflows.

Project description

EMT Logo

Lines of Code Coverage Security Hotspots Technical Debt
Quality Gate Status Reliability Rating Maintainability Rating Security Rating

Energy Monitoring Tool (EMT)

Track and analyze energy usage of your software application(s) — lightweight, reliable and effortless to integrate.

EMT is a lightweight tool capable of tracking and reporting the energy consumption of software systems with process-level granularity. While particularly valuable for compute-intensive workloads like machine learning, it's designed for broad applicability across various use cases. Our mission is to simplify and standardize monitoring and reporting of the energy usage of the the digital realm. By making it visible and accessible, EMT helps teams to reduce their environmental impact and advances digital sustainability.

🚀 Features

  • Real-time energy utilization tracking.
  • Device-level breakdown of energy consumption.
  • Energy/Power attribution to a process of interest in a multi-process shared resource setting.
  • Modular and extendable software architecture, currently supports following powergroups:
    • CPU(s) with RAPL capabilities.
    • Nvidia GPUs.
  • Visualization interface for energy data using TensorBoard, making it easy to analyze energy usage trends.

Supported Platforms & Hardware

  • Linux
  • Hardware
    • Nvidia GPU through NVML
    • Intel & AMD x86 sockets through RAPL

Road Map

  • Environmentally conscious coding tips.
  • Virtual CPU(s) covered by Teads dataset.
  • Add support for Windows through PCM/OpenHardwareMonitor
  • Extend harware support

🌍 Why EMT?

In the era of climate awareness, it's essential for developers to contribute to a sustainable future. EMT Tool empowers you to make informed decisions about your code's impact on the environment and take steps towards writing more energy-efficient software.

🛠️ Getting Started

Install the latest EMT package from the Python Package Index (PyPI):

pip install emt

# verify installation and the version
python -m emt --version

Usage

The tool supports two usage modes:

  • Python Context Manager
    Fully implemented and ideal for instrumenting Python code directly. This mode allows developers to wrap specific code blocks to measure energy consumption with precision.
  • Command-Line Interface (CLI)
    Designed to tag and monitor running application without modifying the code.
    This mode is currently under active development and will be available soon.

Using Python Context Managers

import torch
from emt import EnergyMonitor

# Dummy function
def add_tensors_gpu():
    device = torch.device(device if torch.cuda.is_available() else "cpu")
    # Generate random data
    a = torch.randint(1, 100, (1000,), dtype=torch.int32, device=device)
    b = torch.randint(1, 100, (1000,), dtype=torch.int32, device=device)

    return a + b

# Create a context manager
with EnergyMonitor() as monitor:
    add_tensors_gpu()

print(f"energy consumption: {monitor.consumed_energy}")

Refer to the following folder for example codes: 📁 examples/

Dynamic Child Processes

In some cases, such as when using non-Python applications within a script (s. example below) or when workers are spawned dynamically, the child processes are not be created before the EnergyMonitor, which must therefore reload the child processes.
This can be enabled through the environment variable EMT_RELOAD_PROCS.

import json, os

# Enforce reloading (child) processes
os.environ["EMT_RELOAD_PROCS"] = "1"
from emt import EnergyMonitor

with EnergyMonitor() as monitor:
   # Example: Run non-Python GPU binary
   cmd = "lmp -in input.in -sf gpu"
   os.system(cmd)

print(f"energy consumption: {monitor.consumed_energy}")

⚙️ Methodology

The EMT context manager spawns a separate thread to monitor energy usage for CPUs and GPUs at regular intervals. It also tracks the utilization of these resources by the monitored process. EMT then estimates the process's share of the total energy consumption by proportionally assigning energy usage based on the resource utilization of the process.

EMT Energy Attribution

🤝 Contributions

We welcome contributions to this project! To ensure a smooth review and merge process, please ensure your pull request meets the following requirements:

Code Formatting: All code must be formatted using Black. Please run black . on your changes before committing.
Test Coverage: New features and bug fixes should include tests, achieving at least 80% test coverage for the added or modified code.
Quality Gate: Your pull request must pass all automated quality checks, including those enforced by SonarQube, which ensures our code meets predefined standards for reliability and maintainability.

Thank you for helping us maintain a high-quality codebase!

🚧 Work in Progress

EMT Tool is an ongoing project, and we are actively working to enhance its features and usability. If you encounter any issues or have suggestions, please open an issue on the GitHub repository.

📧 Contact

For any inquiries or discussions, feel free to reach out to us:
Rameez Ismail: rameez.ismail@philips.com
Sophie Thornander: sophie.thornander@philips.com
Arlette van Wissen: arlette.van.wissen@philips.com

Let's code responsibly and make a positive impact on the environment! 🌍✨

Acknowledgment

This project was originally initiated at Philips and continues to be actively maintained by the Philips Responsible AI team. We extend our sincere gratitude to all current and former contributors at Philips whose expertise, vision, and commitment to sustainability have been instrumental in shaping the Energy Monitoring Tool (EMT).

EMT Logo

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

emt-0.0.1a2.tar.gz (768.5 kB view details)

Uploaded Source

Built Distribution

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

emt-0.0.1a2-py3-none-any.whl (27.1 kB view details)

Uploaded Python 3

File details

Details for the file emt-0.0.1a2.tar.gz.

File metadata

  • Download URL: emt-0.0.1a2.tar.gz
  • Upload date:
  • Size: 768.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for emt-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 3774f2ae788139f9f888ccd20856f3fbe015e26efb239c6498e32f5a4c79a030
MD5 84f9ebd63f5bce3da4a25f6a877e1255
BLAKE2b-256 76fd0da664f9c070483b31e4186b56fd09f18ad29a09ff2af70aac6f82bdff5f

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a2.tar.gz:

Publisher: release_request.yml on FairCompute/energy-monitoring-tool

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

File details

Details for the file emt-0.0.1a2-py3-none-any.whl.

File metadata

  • Download URL: emt-0.0.1a2-py3-none-any.whl
  • Upload date:
  • Size: 27.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for emt-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 0a33267c661416441ee59e4b97d206a1f2d52d19c25af272e603dc8ee2b54c24
MD5 65923649a109a17f21e544f4d9b7671b
BLAKE2b-256 4676628d1b0aaedf0c4368db1752340e6670f9d22c7d1301b3a27c63d77ff94f

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a2-py3-none-any.whl:

Publisher: release_request.yml on FairCompute/energy-monitoring-tool

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