You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-to/examples.md
+35-35Lines changed: 35 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,91 +6,91 @@ The directory [examples/](https://github.com/mlco2/codecarbon/tree/master/exampl
6
6
7
7
| Example | Type | Description |
8
8
|---------|------|-------------|
9
-
|[print_hardware.py](../../examples/print_hardware.py)| Python Script | Detect and display available hardware (CPU, GPU, RAM) on your system |
10
-
|[command_line_tool.py](../../examples/command_line_tool.py)| Python Script | Track emissions of external command-line tools executed via subprocess |
9
+
|[print_hardware.py](https://github.com/mlco2/codecarbon/blob/master/examples/print_hardware.py)| Python Script | Detect and display available hardware (CPU, GPU, RAM) on your system |
10
+
|[command_line_tool.py](https://github.com/mlco2/codecarbon/blob/master/examples/command_line_tool.py)| Python Script | Track emissions of external command-line tools executed via subprocess |
11
11
12
12
## Tracking Methods
13
13
14
14
| Example | Type | Description |
15
15
|---------|------|-------------|
16
-
|[mnist_decorator.py](../../examples/mnist_decorator.py)| Python Script | Track emissions using the `@track_emissions` decorator on functions |
17
-
|[mnist_context_manager.py](../../examples/mnist_context_manager.py)| Python Script | Track emissions using `EmissionsTracker` as a context manager (with statement) |
18
-
|[mnist_callback.py](../../examples/mnist_callback.py)| Python Script | Track emissions using Keras/TensorFlow callbacks during model training |
19
-
|[api_call_demo.py](../../examples/api_call_demo.py)| Python Script | Track emissions and send data to the CodeCarbon API with `@track_emissions`|
16
+
|[mnist_decorator.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist_decorator.py)| Python Script | Track emissions using the `@track_emissions` decorator on functions |
17
+
|[mnist_context_manager.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist_context_manager.py)| Python Script | Track emissions using `EmissionsTracker` as a context manager (with statement) |
18
+
|[mnist_callback.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist_callback.py)| Python Script | Track emissions using Keras/TensorFlow callbacks during model training |
19
+
|[api_call_demo.py](https://github.com/mlco2/codecarbon/blob/master/examples/api_call_demo.py)| Python Script | Track emissions and send data to the CodeCarbon API with `@track_emissions`|
20
20
21
21
## Basic Model Training
22
22
23
23
| Example | Type | Description |
24
24
|---------|------|-------------|
25
-
|[mnist.py](../../examples/mnist.py)| Python Script | Train a simple neural network on MNIST dataset with TensorFlow |
26
-
|[mnist-sklearn.py](../../examples/mnist-sklearn.py)| Python Script | Train a scikit-learn model on MNIST and track emissions |
27
-
|[pytorch-multigpu-example.py](../../examples/pytorch-multigpu-example.py)| Python Script | PyTorch CNN training on MNIST with multi-GPU support |
25
+
|[mnist.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist.py)| Python Script | Train a simple neural network on MNIST dataset with TensorFlow |
26
+
|[mnist-sklearn.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist-sklearn.py)| Python Script | Train a scikit-learn model on MNIST and track emissions |
27
+
|[pytorch-multigpu-example.py](https://github.com/mlco2/codecarbon/blob/master/examples/pytorch-multigpu-example.py)| Python Script | PyTorch CNN training on MNIST with multi-GPU support |
|[mnist_random_search.py](https://github.com/mlco2/codecarbon/blob/master/examples/mnist_random_search.py)| Python Script | Random search hyperparameter optimization with emission tracking |
35
35
36
36
## ML Model Inference
37
37
38
38
| Example | Type | Description |
39
39
|---------|------|-------------|
40
-
|[bert_inference.py](../../examples/bert_inference.py)| Python Script | BERT language model inference with task-level tracking |
41
-
|[task_inference.py](../../examples/task_inference.py)| Python Script | Track emissions for different inference tasks (load dataset, build model, predict) |
42
-
|[task_loop_same_task.py](../../examples/task_loop_same_task.py)| Python Script | Track emissions running the same task multiple times |
43
-
|[transformers_smollm2.py](../../examples/transformers_smollm2.py)| Python Script | Small language model (SmolLM2) inference from Hugging Face |
44
-
|[ollama_local_api.py](../../examples/ollama_local_api.py)| Python Script | Track emissions of local LLM API calls using Ollama |
40
+
|[bert_inference.py](https://github.com/mlco2/codecarbon/blob/master/examples/bert_inference.py)| Python Script | BERT language model inference with task-level tracking |
41
+
|[task_inference.py](https://github.com/mlco2/codecarbon/blob/master/examples/task_inference.py)| Python Script | Track emissions for different inference tasks (load dataset, build model, predict) |
42
+
|[task_loop_same_task.py](https://github.com/mlco2/codecarbon/blob/master/examples/task_loop_same_task.py)| Python Script | Track emissions running the same task multiple times |
43
+
|[transformers_smollm2.py](https://github.com/mlco2/codecarbon/blob/master/examples/transformers_smollm2.py)| Python Script | Small language model (SmolLM2) inference from Hugging Face |
44
+
|[ollama_local_api.py](https://github.com/mlco2/codecarbon/blob/master/examples/ollama_local_api.py)| Python Script | Track emissions of local LLM API calls using Ollama |
45
45
46
46
## Hardware-Specific Examples
47
47
48
48
| Example | Type | Description |
49
49
|---------|------|-------------|
50
-
|[intel_npu.py](../../examples/intel_npu.py)| Python Script | Intel Neural Processing Unit (NPU) support for model inference |
51
-
|[full_cpu.py](../../examples/full_cpu.py)| Python Script | Demonstrate full CPU utilization and emission tracking |
50
+
|[intel_npu.py](https://github.com/mlco2/codecarbon/blob/master/examples/intel_npu.py)| Python Script | Intel Neural Processing Unit (NPU) support for model inference |
51
+
|[full_cpu.py](https://github.com/mlco2/codecarbon/blob/master/examples/full_cpu.py)| Python Script | Demonstrate full CPU utilization and emission tracking |
52
52
53
53
## Parallel & Concurrent Processing
54
54
55
55
| Example | Type | Description |
56
56
|---------|------|-------------|
57
-
|[multithread.py](../../examples/multithread.py)| Python Script | Track emissions from multithreaded workloads |
58
-
|[compare_cpu_load_and_RAPL.py](../../examples/compare_cpu_load_and_RAPL.py)| Python Script | Compare RAPL power measurement vs CPU load estimation in parallel workloads |
57
+
|[multithread.py](https://github.com/mlco2/codecarbon/blob/master/examples/multithread.py)| Python Script | Track emissions from multithreaded workloads |
58
+
|[compare_cpu_load_and_RAPL.py](https://github.com/mlco2/codecarbon/blob/master/examples/compare_cpu_load_and_RAPL.py)| Python Script | Compare RAPL power measurement vs CPU load estimation in parallel workloads |
59
59
60
60
## Logging & Output Integration
61
61
62
62
| Example | Type | Description |
63
63
|---------|------|-------------|
64
-
|[logging_to_file.py](../../examples/logging_to_file.py)| Python Script | Save emissions data to a local CSV file |
65
-
|[logging_to_file_exclusive_run.py](../../examples/logging_to_file_exclusive_run.py)| Python Script | Long-running process with exclusive file logging |
66
-
|[logging_to_google_cloud.py](../../examples/logging_to_google_cloud.py)| Python Script | Send emissions data to Google Cloud Logging |
|[logging_to_file.py](https://github.com/mlco2/codecarbon/blob/master/examples/logging_to_file.py)| Python Script | Save emissions data to a local CSV file |
65
+
|[logging_to_file_exclusive_run.py](https://github.com/mlco2/codecarbon/blob/master/examples/logging_to_file_exclusive_run.py)| Python Script | Long-running process with exclusive file logging |
66
+
|[logging_to_google_cloud.py](https://github.com/mlco2/codecarbon/blob/master/examples/logging_to_google_cloud.py)| Python Script | Send emissions data to Google Cloud Logging |
|[pue.py](../../examples/pue.py)| Python Script | Calculate Power Usage Effectiveness (PUE) with CodeCarbon |
76
-
|[wue.py](../../examples/wue.py)| Python Script | Calculate Water Usage Effectiveness (WUE) of your computing |
75
+
|[pue.py](https://github.com/mlco2/codecarbon/blob/master/examples/pue.py)| Python Script | Calculate Power Usage Effectiveness (PUE) with CodeCarbon |
76
+
|[wue.py](https://github.com/mlco2/codecarbon/blob/master/examples/wue.py)| Python Script | Calculate Water Usage Effectiveness (WUE) of your computing |
|[compare_cpu_load_and_RAPL.ipynb](../../examples/compare_cpu_load_and_RAPL.ipynb)| Jupyter Notebook | Compare different power measurement methods (RAPL vs CPU load) |
84
-
|[local_llms.ipynb](../../examples/local_llms.ipynb)| Jupyter Notebook | Track emissions of local LLM inference |
|[compare_cpu_load_and_RAPL.ipynb](https://github.com/mlco2/codecarbon/blob/master/examples/compare_cpu_load_and_RAPL.ipynb)| Jupyter Notebook | Compare different power measurement methods (RAPL vs CPU load) |
84
+
|[local_llms.ipynb](https://github.com/mlco2/codecarbon/blob/master/examples/local_llms.ipynb)| Jupyter Notebook | Track emissions of local LLM inference |
85
85
86
86
## Setup & Configuration
87
87
88
88
| Item | Description |
89
89
|------|-------------|
90
-
|[requirements-examples.txt](../../examples/requirements-examples.txt)| Python dependencies for running the examples |
91
-
|[rapl/](../../examples/rapl/)| Setup instructions for RAPL power measurement support |
92
-
|[slurm_rocm/](../../examples/slurm_rocm/)| Configuration for SLURM job scheduler with ROCm GPU support |
|[requirements-examples.txt](https://github.com/mlco2/codecarbon/blob/master/examples/requirements-examples.txt)| Python dependencies for running the examples |
91
+
|[rapl/](https://github.com/mlco2/codecarbon/blob/master/examples/rapl/)| Setup instructions for RAPL power measurement support |
92
+
|[slurm_rocm/](https://github.com/mlco2/codecarbon/blob/master/examples/slurm_rocm/)| Configuration for SLURM job scheduler with ROCm GPU support |
0 commit comments