Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhou0515 committed Dec 14, 2024
1 parent f18bf16 commit f8787c9
Show file tree
Hide file tree
Showing 8 changed files with 1,664 additions and 103 deletions.
31 changes: 31 additions & 0 deletions examples/carbon_emission_monitor/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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/energy/#zeus.monitor.energy.ZeusMonitor): 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
# For Trainer.
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 f8787c9

Please sign in to comment.