Skip to main content
EcoTrace Logo

EcoTrace

High-Precision Energy and Emissions Instrumentation


v1.6.1 — HuggingFace Integration, CodeCarbon Drop-in API & Metrology Study. Native HuggingFace Trainer callback, CodeCarbon-compatible API layer (EmissionsTracker), Case 08 Metrology & Overhead benchmark, and Zenodo DOI archival integration.

EcoTrace is a lightweight library for granular carbon footprint measurement of Python applications. No configuration files, no background services—just real-time hardware-level transparency.

Real-time monitoring | 50+ Global Zones | AI-powered insights | Zero-configuration


Official Website PyPI - Version Python 3.8+ License: MIT Downloads Join Discord VS Code Extension Technical Whitepaper



EcoTrace Demo

Function-level carbon measurement with real-time monitoring


Core Features in v1.6.0

Latest Release. v1.6.0 introduces automated multi-GPU continuous power tracking, DDR3 RAM hardware detection, a persistent offline disk retry queue for cloud telemetry, and a comprehensive type safety overhaul.

  • Automated Multi-GPU Tracking & Aggregation (ecotrace.gpu) — Automatically discovers all available NVIDIA GPUs via NVML (get_all_gpu_info) and aggregates instantaneous power draw at 50ms intervals across active accelerators (get_all_gpu_power_w).
  • Comprehensive Multi-Device Telemetry — Startup logs, session summaries, and exported JSON/CSV artifacts now report full GPU array metadata (total GPU count, device models, and combined TDP limit).
  • Offline Disk Retry Queue (CloudExporter) — Telemetry payloads are safely persisted to an isolated local disk queue (~/.ecotrace/retry_queue) during network outages or backend 5xx errors, automatically flushing in chronological FIFO order (up to 50 entries) upon reconnection.
  • DDR3 RAM Speed Detection (ecotrace.ram) — Evaluates memory clock frequencies (800–2133 MHz) via Linux dmidecode and Windows WMI, applying calibrated DDR3 power factors (0.500 W/GB) for accurate carbon accounting on legacy enterprise hardware.
  • Strict Static Type Safety & Diagnostics Overhaul — Complete overhaul eliminating # type: ignore workarounds across core.py, gpu.py, and exporters, achieving clean IDE diagnostics under Pyright/Pylance and hardened exception handling.
  • Unified Multi-Device Architecture — Deprecates single-device gpu_index targeting in favor of unified multi-accelerator tracking, emitting a backward-compatible DeprecationWarning if gpu_index > 0 is passed.

Quick Install

pip install ecotrace

Optional extras:

pip install ecotrace[gpu]   # NVIDIA GPU support
pip install ecotrace[ai]    # Gemini AI insights
pip install ecotrace[all]   # Everything

Quick Start

Option 1: Zero-Code Profiling (CLI + Cloud Sync)

Authenticate your terminal once, then profile any script without changing source code:

# 1. Login with your ingestion key from https://ecotracelibrary.com
ecotrace login --key eco_usr_abc123...

# 2. Run your script — metrics automatically stream to your web dashboard!
ecotrace run my_script.py

Option 2: Programmatic Tracking & Cloud Dashboard

Decorate functions for granular instrumentation and stream metrics to your web account:

from ecotrace import EcoTrace

# Connects directly to your hosted account at https://ecotracelibrary.com
eco = EcoTrace(api_key="eco_usr_abc123...", region_code="US")

@eco.track
def my_function():
    # Your heavy processing here
    pass

my_function()

# Export audit-ready reports or check cumulative totals
eco.generate_pdf_report("carbon_audit.pdf")
print(f"Total Carbon Emitted: {eco.total_carbon} gCO2")

Option 3: Carbon Budget Mode

Set a limit and let EcoTrace enforce it:

eco = EcoTrace(
    region_code="TR",
    carbon_limit=5.0,                   # 5 gCO2 budget
    on_budget_exceeded=lambda t, l: print(f"Budget exceeded: {t:.4f}/{l:.4f} gCO2")
)

@eco.track
def training_pipeline():
    ...

training_pipeline()
print(f"Remaining budget: {eco.remaining_budget} gCO2")

Expected Output

When initialized, EcoTrace performs automated hardware detection:

[EcoTrace] INFO: [INFO] EcoTrace instrumentation session initialized (STATIC).
[EcoTrace] INFO: -----------------------------------------------------
[EcoTrace] INFO: Region        : TR (475 gCO2/kWh)
[EcoTrace] INFO: Hardware Logic: 13th Gen Intel Core i7-13700H
[EcoTrace] INFO: Specifications: 20 Cores | 45.0W TDP
[EcoTrace] INFO: Energy Sensor : Boavizta Advanced Estimation
[EcoTrace] INFO: Memory Config : 15.6 GB DDR4
[EcoTrace] INFO: GPU Accelerator: Intel Iris Xe Graphics (15.0W TDP)
[EcoTrace] INFO: -----------------------------------------------------

At process exit, a session summary is printed automatically:

=======================================================
  EcoTrace — Session Summary
=======================================================
  Duration       : 12.34s
  Functions      : 5 tracked
  Total Carbon   : 0.00312000 gCO2
  Region         : TR (475 gCO2/kWh)
  Budget         : 0.003120 / 5.000000 gCO2 (0.1%) [OK]
  Equivalent     : 0.4 min of LED bulb (10W)
=======================================================

CI/CD Integration

Official GitHub Action

Enforce carbon budgets in your pipeline with our official GitHub Action. Add this to your .github/workflows/ci.yml:

- name: EcoTrace Carbon Gate
  uses: Zwony/ecotrace@v1.6.0
  with:
    budget: '10.0'
    region: 'US'

Manual CLI Integration

You can also run the gate manually:

ecotrace gate --budget 10.0

If total emissions exceed the budget, the gate fails with exit code 1 — preventing carbon-heavy code from being merged.


Why EcoTrace?

Feature EcoTrace v1.6 CodeCarbon CarbonTracker
Sampling Interval 50ms 15s Per Epoch
Isolation Process-scoped System-wide System-wide
Cloud Dashboard Sync Native No No
Multi-GPU Tracking Continuous (Aggregated) Single GPU Per Epoch
CPU Dataset 6,980+ CPUs Limited Limited
Budget Enforcement Built-in No No
CI/CD Gate Built-in No No
Idle Noise Subtraction Automatic No No
Async Support Native Limited No
  • Deep Transparency: Derived from 6,980+ verified manufacturer TDP specifications rather than category averages.
  • Fail-Safe Architecture: Guaranteed application continuity even if hardware drivers or API keys are missing.
  • Actionable AI: Integrates with Google Gemini to provide specific code optimization advice (optional).

Academic Benchmarks & Empirical Research

EcoTrace includes a reproducible Academic Benchmark Suite designed for peer-reviewed green computing research. Every article in benchmarks/articles/ is auto-generated from real measurement JSONs in benchmarks/results/ by benchmarks/report_generator.py — re-run the generator after new measurements to keep the published numbers in sync.

Citing EcoTrace

If you use EcoTrace or its benchmark suite in scientific publications:

@software{ozkal2026ecotrace,
  author = {Ozkal, Emre},
  title = {EcoTrace: High-Precision Energy and Emissions Instrumentation for Python},
  year = {2026},
  url = {https://github.com/Zwony/ecotrace},
  version = {1.6.0}
}

Documentation

Full documentation is available at ecotracelibrary.com and ecotrace.readthedocs.io.


Contributing

We welcome contributions! Please see our CONTRIBUTING.MD for guidelines on reporting bugs, suggesting features, or contributing hardware data.


Community

Join Discord

CHANGELOG.md · SECURITY.MD


Author and License

Emre Ozkal — GitHub · ecotraceteam@gmail.com

MIT License — Use it however you like.

Developed for sustainable software development practices.

Metadata

Release files for ecotrace 1.6.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ecotrace 1.6.1
File Size Uploaded
ecotrace-1.6.1.tar.gz 175.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ecotrace 1.6.1
File Interpreter ABI Platform
ecotrace-1.6.1-py3-none-any.whl Python 3 none any Details

Total release size: 340.8 kB

Release files / ecotrace-1.6.1.tar.gz

Download URL ecotrace-1.6.1.tar.gz
Size 175.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7b1c81a0ec128f8699a34a937ff5d07c146dde5fe32b63ada388157e07f6e0a1
BLAKE2b-256 checksum
How to use checksums
30b8d693b1ecdabbe58a59bf675314f7d266535e21f34d0982507fee4f6fa0d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.1

Release files / ecotrace-1.6.1-py3-none-any.whl

Download URL ecotrace-1.6.1-py3-none-any.whl
Size 165.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ed43c909d16287b38edca357b15b35f4b1f389229392958e2c7bbbeaf505b6
BLAKE2b-256 checksum
How to use checksums
bba45e3cd871148c19a3943a3ae7790a9e92182b7de1d0486da3cdb3db9587c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.1

Release history Release notifications | RSS feed

1.7.0

2 release files

This release

1.6.1 This release

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.2

2 release files

1.1.0

2 release files

1.0.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page