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

# One time configuration to allow access to the RAPL files
emt_cfgup

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

📧 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.1a3.tar.gz (951.1 kB view details)

Uploaded Source

Built Distributions

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

emt-0.0.1a3-cp312-cp312-manylinux_2_34_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

emt-0.0.1a3-cp311-cp311-manylinux_2_34_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

emt-0.0.1a3-cp310-cp310-manylinux_2_34_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

File details

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

File metadata

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

File hashes

Hashes for emt-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 63cef17c2189256f1d6a7112fa4d7894a894bc2d02a803323e4d848aee42018c
MD5 4c4f8dbe610e3c3d8f68e1a6365367f4
BLAKE2b-256 065c29e357ceaffc6ab562fd3f8c76d05b9b443bd862fe7f584cb1e272059685

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a3.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.1a3-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for emt-0.0.1a3-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 a9dad6817b4abc6cd4e822c147f54ec62679e6bff742399390b1e478200dd9d8
MD5 4b18a08bb2b075b96b19e4bdf32b3205
BLAKE2b-256 ca4ab9eb31accc544773826118dd946dec6c4bc46d84caa76c5442ca47fcdff1

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a3-cp312-cp312-manylinux_2_34_x86_64.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.

File details

Details for the file emt-0.0.1a3-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for emt-0.0.1a3-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 90ac014b9f71dd226753b93ce5c3c42cc09f1cd0debd066c6b922fb75e14e835
MD5 5b64255caed9f1e51dd0e6f66eb3ad0a
BLAKE2b-256 7f5652eb644711121de3dbddec3bd332a120f7b8d68b301af31f4492241aa709

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a3-cp311-cp311-manylinux_2_34_x86_64.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.

File details

Details for the file emt-0.0.1a3-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for emt-0.0.1a3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 21a9e2cde580b0d224195f3fdc787c51108f7d7726a4cfc3b49aae098a49ecfc
MD5 173429bb2a1b4b1d8134203982892029
BLAKE2b-256 27e2bb4b7beabd6aab3577853ff7eaf069f976d3ae660dc9043295a0b4d12a17

See more details on using hashes here.

Provenance

The following attestation bundles were made for emt-0.0.1a3-cp310-cp310-manylinux_2_34_x86_64.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