Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ae52042
added amd-smi interface
IlyasMoutawwakil Jan 16, 2024
1b8c799
fix energy unit
IlyasMoutawwakil Jan 16, 2024
00d01d9
use counter_resolution instead of hard coding it
IlyasMoutawwakil Jan 16, 2024
91b551a
wip : handle AMD and Nvidia at the same time
Jan 26, 2024
3a0571d
added support for amd and nvidia at the same time
IlyasMoutawwakil Jan 29, 2024
c24c1f8
Fix merge conflict
Feb 18, 2026
4b25b01
Upgrade AMDSMI entries
Feb 18, 2026
1d11bc9
Breaking change : Watt
Mar 4, 2026
a5c8949
Adastra
Mar 4, 2026
7601a3e
Contributing to a PR
Mar 4, 2026
17ccee3
fix merge errors
Mar 4, 2026
ef94530
Warn about dual GCD
Mar 5, 2026
bdc3c1d
Fix GPU tests
Mar 5, 2026
330aa6e
Matrix multiplication across all devices
Mar 5, 2026
9ba8d2e
Warn about dual GCD
Mar 5, 2026
cadeec8
Docs on power estimation
Mar 5, 2026
af7c0dc
Adastra
Mar 5, 2026
3b5d8f8
Docs on power estimation
Mar 5, 2026
983bb87
Fix start()
Mar 5, 2026
8c93404
Fix too much call to _get_gpu_ids
Mar 5, 2026
1798e44
MI300
Mar 5, 2026
18e0857
Fix _get_power_usage
Mar 5, 2026
f0ef29b
Handle SLURM CPU allocation for default TDP
Mar 5, 2026
ddfde21
Exclude MI210 single GCD
Mar 5, 2026
faf9199
Remove login sensitive informations
Mar 5, 2026
ad59dc3
fix tests
Mar 5, 2026
5930507
Add tests
Mar 5, 2026
332a675
wip: refacto GPU
Mar 7, 2026
dd2ade2
fix test
Mar 7, 2026
f3b0425
Docs and split GPU tests
Mar 7, 2026
be47ad7
Suggest OffLine mode in the CLI
benoit-cty Mar 8, 2026
42a423b
Debug log for PUE
benoit-cty Mar 8, 2026
c6911fe
pre-commit
benoit-cty Mar 8, 2026
79db8c9
remove commented lines
benoit-cty Mar 8, 2026
4fee98a
review on emit_selection_warning
benoit-cty Mar 8, 2026
ac14e41
fix test cli
benoit-cty Mar 8, 2026
5691495
doc
benoit-cty Mar 8, 2026
d0fc028
fix tests/test_gpu_amd.py
benoit-cty Mar 8, 2026
ef9ac99
Add _normalize_gpu_ids
Mar 14, 2026
b8b2288
Documentation
Mar 14, 2026
57d60f2
Potential fix for code scanning alert no. 44: Clear-text logging of s…
benoit-cty Mar 14, 2026
a429a4b
lint
Mar 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ flake8...................................................................Passed

If any of the linters/formatters fail, check the difference with `git diff`, add the differences if there is no behavior changes (isort and black might have change some coding style or import order, this is expected it is their job) with `git add` and finally try to commit again `git commit ...`.

You can also run `pre-commit` with `uv run pre-commit run -v` if you have some changes staged but you are not ready yet to commit.
You can also run `pre-commit` with `uv run pre-commit run --all-file` to check all file.


<!-- TOC --><a name="dependencies-management"></a>
Expand Down Expand Up @@ -363,6 +363,18 @@ cp /data/tests/test_package_integrity.py .
pytest test_package_integrity.py
```

### Contribute to a fork branch

When a user open a PR from a fork, we are allowed to push to the fork branch.

If you want to do so, do the following:

```bash
git remote add <user_name> https://github.com/<user_name>/codecarbon.git
git fetch <user_name> <git_branch>
git checkout -b <git_branch> <user_name>/<git_branch>
```

<!-- TOC --><a name="api-and-dashboard"></a>
## API and Dashboard

Expand Down
5 changes: 3 additions & 2 deletions codecarbon/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ def monitor(
if offline:
if not country_iso_code:
print(
Comment thread
benoit-cty marked this conversation as resolved.
"ERROR: country_iso_code is required for offline mode", file=sys.stderr
"ERROR: Country ISO code is required for offline mode. Add it to your configuration or provide it via the command line: `--country-iso-code FRA`",
file=sys.stderr,
)
raise typer.Exit(1)

Expand All @@ -358,7 +359,7 @@ def monitor(
experiment_id = get_existing_local_exp_id()
if api and experiment_id is None:
print(
"ERROR: No experiment id, call 'codecarbon config' first.",
"ERROR: No experiment id, call 'codecarbon config' first. Or run in offline mode with `--offline --country-iso-code FRA` flag if you don't want to connect to the API.",
file=sys.stderr,
)
raise typer.Exit(1)
Expand Down
39 changes: 38 additions & 1 deletion codecarbon/core/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
import os
from pathlib import Path
from typing import List, Union
from typing import List, Optional, Union

from codecarbon.external.logger import logger

Expand Down Expand Up @@ -73,6 +73,43 @@ def parse_gpu_ids(gpu_ids: Union[str, List[int]]) -> List[str]:
)


def normalize_gpu_ids(
gpu_ids: Optional[Union[str, List[Union[int, str]]]],
) -> Optional[List[Union[int, str]]]:
"""
Normalize GPU IDs from config/user input into a list of ids consumable by hardware
resolution code.

Supports:
- comma-separated string values (sanitized via parse_gpu_ids)
- lists containing ints and/or strings
"""
if gpu_ids is None:
return None

if isinstance(gpu_ids, str):
return parse_gpu_ids(gpu_ids)

if isinstance(gpu_ids, list):
normalized_gpu_ids: List[Union[int, str]] = []
for gpu_id in gpu_ids:
if isinstance(gpu_id, int):
normalized_gpu_ids.append(gpu_id)
elif isinstance(gpu_id, str):
normalized_gpu_ids.extend(parse_gpu_ids(gpu_id))
else:
logger.warning(
"Ignoring invalid gpu_id entry of type %s; expected int or str.",
type(gpu_id).__name__,
)
return normalized_gpu_ids

logger.warning(
"Invalid gpu_ids format. Expected a string or a list of ints/strings."
)
return None


def get_hierarchical_config():
"""
Get the user-defined codecarbon configuration ConfigParser dictionnary
Expand Down
4 changes: 2 additions & 2 deletions codecarbon/core/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from codecarbon.core.rapl import RAPLFile
from codecarbon.core.units import Time
from codecarbon.core.util import detect_cpu_model
from codecarbon.core.util import count_cpus, detect_cpu_model
from codecarbon.external.logger import logger
from codecarbon.input import DataSource

Expand Down Expand Up @@ -1001,7 +1001,7 @@ def _main(self) -> Tuple[str, int]:
)
if is_psutil_available():
# Count thread of the CPU
threads = psutil.cpu_count(logical=True)
threads = count_cpus()
estimated_tdp = threads * DEFAULT_POWER_PER_CORE
logger.warning(
f"We will use the default power consumption of {DEFAULT_POWER_PER_CORE} W per thread for your {threads} CPU, so {estimated_tdp}W."
Expand Down
Loading
Loading