Skip to main content

GAtorch

Green AI torch tries to create awereness over energy consumption within the Pytorch ML framework. Its goal is to measure energy consumption throughout the complete process of AI engineers and can give overviews and indications for performance gains with respect to energy consumption.

Currently it supports energy measurement of the training passes per layer.

Installation requirements

  • cuda >=11.7
  • cuDNN >=8

Create a virtualenv like virtualenv .venv and activate it using source ./.venv/bin/activate and install the other requirements with pip install requirements.txt.

Basic example

from GA import GA

# Create the profiler object and attach a model to it
ga_measure = GA()
ga_measure.attach_model(model)

# Let's try to do a single forward pass and a backward pass
x = torch.zeros([1, 1, 28, 28]).to(device)
y = torch.zeros([1, 10]).to(device)
pred = model(x) # forward

loss = loss_fn(pred, y)
optimizer.zero_grad()
loss.backward() # backward
optimizer.step()

# Now lets print the mean measurements
print(ga_measure.get_mean_measurements())

or run the example scripts in the examples directory.

Compatability

Some older hardware might not support energy consumption measurements:

  • NVML requires Tesla Architecture NVIDIA GPUs or newer to work.
  • RAPLs DRAM measurements are only available for XENON CPUs.

In case you get compatibility errors due to older hardware you can disable the failing measurement application, use the disable_measurements parameter in the attach_model function. This parameter accepts a list of disabled measurements out of ['cpu', 'ram', 'gpu'], default is []. You need to use at least one measurement that is not disabled. The program will indicate that the disabled devices are unavailable.

Permissions

Due to Platypus attack Intel RAPL requires root permission for energy readings. In order to run this program with the correct permissions, do NOT make Intel RAPL readable for any user as this introduces vulernability. Instead use Python with sudo instead:

sudo ./.venv/bin/python <script_name>.py

Tensorboard

This tool can automatically generate energy consumption reports and display these in Tensorboard. To use Tensorboard run tensorboard --logdir=runs and open the browser to view the graphs. This tool further allows for custom graph generation and tensorboard integration, but is not complete and needs to be extended.

Roadmap

The current architecture of this tool uses the integrated hooks of the PyTorch library, which restricts the current implementation towards the final goal of complete coverage including data loading, pre-processing, saving and loading a model etc. To give a more thorough analysis of the imapct of energy consumption in ML development, this still needs to be developed.

This tool differes from other tools by measuring in-depth layers and system componenents and could be expanded to provide energy consumption data that can lead to recommendations for eliminating certain layers due to high energy consumption compared to accuracy gain.

PyJoules measures the energy consumption per individual hardware components and this data could be sereperated in order to provide a relative component view. Another improvement could be to measure the system component utilisation over time, which can be an indicator of wasted energy.

Metadata

Release files for GATorch 0.0.2

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

Source distribution (sdist)

Source distribution for GATorch 0.0.2
File Size Uploaded
GATorch-0.0.2.tar.gz 8.2 kB Details

Built distribution (wheel)

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

Total release size: 17.8 kB

Release files / GATorch-0.0.2.tar.gz

Download URL GATorch-0.0.2.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
608d5042a802e6ffeb05cf47a15b28bd85154b829b77cbf670a15766756147c0
BLAKE2b-256 checksum
How to use checksums
45d71d4cf5ffdc14e4dd766cae04e59df2575f3e7ea1fd69b19d6ccc5c77b266
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / GATorch-0.0.2-py3-none-any.whl

Download URL GATorch-0.0.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77e827c6ad8f35a2dd811048051b97bc0f799ba8d4947399c3eaa3c6a74a2bea
BLAKE2b-256 checksum
How to use checksums
b050ff4ffa7f4d09242a6b744c6ada9ce02d65cd4f172f9c9aefd845fe1f402f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

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