Skip to main content

GATorch is a tool seamlessly integrated with PyTorch that enables ML developers to generate an energy consumption report. By attaching your model, the tool automatically tracks the energy consumption of your model's training and generates graphs and plots to gain in-depth insights into the energy consumption of your model.

Project description

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.

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

GATorch-0.0.2.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

GATorch-0.0.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file GATorch-0.0.2.tar.gz.

File metadata

  • Download URL: GATorch-0.0.2.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for GATorch-0.0.2.tar.gz
Algorithm Hash digest
SHA256 608d5042a802e6ffeb05cf47a15b28bd85154b829b77cbf670a15766756147c0
MD5 4e1af48fa829d758656f2c1784ab9817
BLAKE2b-256 45d71d4cf5ffdc14e4dd766cae04e59df2575f3e7ea1fd69b19d6ccc5c77b266

See more details on using hashes here.

File details

Details for the file GATorch-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: GATorch-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for GATorch-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 77e827c6ad8f35a2dd811048051b97bc0f799ba8d4947399c3eaa3c6a74a2bea
MD5 4305ea8b8eb32722862d0665d9998130
BLAKE2b-256 b050ff4ffa7f4d09242a6b744c6ada9ce02d65cd4f172f9c9aefd845fe1f402f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page