GATorch


NameGATorch JSON
Version 0.0.2 PyPI version JSON
download
home_page
SummaryGATorch 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.
upload_time2023-03-31 20:00:32
maintainer
docs_urlNone
author
requires_python>=3.7
license
keywords pytorch green ai sustainable software software
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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
```python
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
<!-- In case you get a permission error, run:
```bash
sudo chmod -R a+r /sys/class/powercap/intel-rapl
``` 
DONT DO THIS, THIS IS A SECURITY VULNERABILITY
-->
Due to [Platypus attack](https://platypusattack.com) 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:
```bash
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. 

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "GATorch",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "PyTorch,Green AI,sustainable software software",
    "author": "",
    "author_email": "Rover van der Noort <s.r.vandernoort@student.tudelft.nl>, Martijn Smits <m.j.p.smits@student.tudelft.nl>, Dajt Mullaj <d.mullaj@student.tudelft.nl>, Remy Duijsens <r.w.j.p.duijsens@student.tudelft.nl>",
    "download_url": "https://files.pythonhosted.org/packages/45/d7/1d4cf5ffdc14e4dd766cae04e59df2575f3e7ea1fd69b19d6ccc5c77b266/GATorch-0.0.2.tar.gz",
    "platform": null,
    "description": "# GAtorch\n\nGreen 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. \n\nCurrently it supports energy measurement of the training passes per layer. \n\n# Installation requirements\n- cuda >=11.7\n- cuDNN >=8\n\nCreate a virtualenv like `virtualenv .venv` and activate it using `source ./.venv/bin/activate` and install the other requirements with `pip install requirements.txt`.\n\n## Basic example\n```python\nfrom GA import GA\n\n# Create the profiler object and attach a model to it\nga_measure = GA()\nga_measure.attach_model(model)\n\n# Let's try to do a single forward pass and a backward pass\nx = torch.zeros([1, 1, 28, 28]).to(device)\ny = torch.zeros([1, 10]).to(device)\npred = model(x) # forward\n\nloss = loss_fn(pred, y)\noptimizer.zero_grad()\nloss.backward() # backward\noptimizer.step()\n\n# Now lets print the mean measurements\nprint(ga_measure.get_mean_measurements())\n```\n\nor run the example scripts in the `examples` directory.\n\n## Compatability\n\nSome older hardware might not support energy consumption measurements:\n- NVML requires Tesla Architecture NVIDIA GPUs or newer to work.\n- RAPLs DRAM measurements are only available for XENON CPUs. \n\nIn 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. \n\n## Permissions\n<!-- In case you get a permission error, run:\n```bash\nsudo chmod -R a+r /sys/class/powercap/intel-rapl\n``` \nDONT DO THIS, THIS IS A SECURITY VULNERABILITY\n-->\nDue to [Platypus attack](https://platypusattack.com) 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:\n```bash\nsudo ./.venv/bin/python <script_name>.py\n```\n\n## Tensorboard\nThis 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.  \n\n# Roadmap\n\nThe 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.\n\nThis 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. \n\nPyJoules 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. \n",
    "bugtrack_url": null,
    "license": "",
    "summary": "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.",
    "version": "0.0.2",
    "split_keywords": [
        "pytorch",
        "green ai",
        "sustainable software software"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b050ff4ffa7f4d09242a6b744c6ada9ce02d65cd4f172f9c9aefd845fe1f402f",
                "md5": "4305ea8b8eb32722862d0665d9998130",
                "sha256": "77e827c6ad8f35a2dd811048051b97bc0f799ba8d4947399c3eaa3c6a74a2bea"
            },
            "downloads": -1,
            "filename": "GATorch-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4305ea8b8eb32722862d0665d9998130",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9529,
            "upload_time": "2023-03-31T20:00:30",
            "upload_time_iso_8601": "2023-03-31T20:00:30.817104Z",
            "url": "https://files.pythonhosted.org/packages/b0/50/ff4ffa7f4d09242a6b744c6ada9ce02d65cd4f172f9c9aefd845fe1f402f/GATorch-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "45d71d4cf5ffdc14e4dd766cae04e59df2575f3e7ea1fd69b19d6ccc5c77b266",
                "md5": "4e1af48fa829d758656f2c1784ab9817",
                "sha256": "608d5042a802e6ffeb05cf47a15b28bd85154b829b77cbf670a15766756147c0"
            },
            "downloads": -1,
            "filename": "GATorch-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "4e1af48fa829d758656f2c1784ab9817",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8245,
            "upload_time": "2023-03-31T20:00:32",
            "upload_time_iso_8601": "2023-03-31T20:00:32.145591Z",
            "url": "https://files.pythonhosted.org/packages/45/d7/1d4cf5ffdc14e4dd766cae04e59df2575f3e7ea1fd69b19d6ccc5c77b266/GATorch-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-31 20:00:32",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "gatorch"
}
        
Elapsed time: 0.05191s