Skip to content

Commit

Permalink
[feat] CarbonEmissionMonitor (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhou0515 authored Dec 22, 2024
1 parent f18bf16 commit c5e09ed
Show file tree
Hide file tree
Showing 10 changed files with 1,861 additions and 206 deletions.
30 changes: 30 additions & 0 deletions examples/carbon_emission_monitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Integrating Zeus with HuggingFace 🤗

This example will demonstrate how to integrate Zeus's `CarbonEmissionMonitor` with HuggingFace Transformers:

`run_clm.py`: Transformers [`Trainer`](https://huggingface.co/docs/transformers/main_classes/trainer) for **causal langauge modeling** (i.e., pre-training)

## Dependencies

To run the `Trainer` integration script (`run_clm.py`):
```sh
pip install -r requirements.txt

## `CarbonEmissionMonitor`

[`CarbonEmissionMonitor`](https://ml.energy/zeus/reference/monitor/carbon/#zeus.monitor.carbon.CarbonEmissionMonitor): Measures the GPU time, energy consumption, and carbon emission of arbitrary code blocks.

## Running the Example

By default, `Trainer` will make use of all available GPUs. If you would like to use only a subset of the GPUs, specify the `CUDA_VISIBLE_DEVICES` environment variable, which Zeus will also automatically respect.

```bash
python run_clm.py \
--model_name_or_path gpt2 \
--dataset_name wikitext \
--dataset_config_name wikitext-2-raw-v1 \
--per_device_train_batch_size 8 \
--per_device_eval_batch_size 8 \
--do_train \
--do_eval \
--output_dir /tmp/test-clm
9 changes: 9 additions & 0 deletions examples/carbon_emission_monitor/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
zeus-ml
accelerate >= 0.12.0
torch >= 1.3
datasets >= 1.8.0
sentencepiece != 0.1.92
protobuf
evaluate
scikit-learn
transformers>=4.37.2
Loading

0 comments on commit c5e09ed

Please sign in to comment.