count_cpus() and RAM crash with FileNotFoundError when SLURM_JOB_ID is set but scontrol is missing
维护者通常 2 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 codecarbon/core/util.py 中的 count_cpus() 和 codecarbon/external/ram.py 中的 RAM._read_slurm_scontrol() 开始,然后检查现有的 CalledProcessError 回退路径。为每种缺少 scontrol 的情况添加测试,并确认两者都会发出警告,回退到机器的 CPU 数量或总 RAM。
由索引模型根据 Issue 内容生成。
描述
Problem
count_cpus() (codecarbon/core/util.py) and RAM._read_slurm_scontrol() (codecarbon/external/ram.py) only catch subprocess.CalledProcessError. When SLURM_JOB_ID is set but the scontrol binary is not on PATH, subprocess.check_output raises FileNotFoundError instead, which is not caught.
This happens for example when a job runs inside a container (Docker / Apptainer) launched by SLURM: the SLURM env vars propagate but the SLURM client tools are not installed. The tracker then records no emissions and tracker.stop() returns None.
Reproduction
SLURM_JOB_ID=123 python -c "from codecarbon.core.util import count_cpus; count_cpus()"
# FileNotFoundError: [Errno 2] No such file or directory: 'scontrol'
Expected
Fall back to the machine's CPU count / total RAM with a warning, the same way the existing CalledProcessError path does.
Proposed fix
Catch (subprocess.CalledProcessError, FileNotFoundError) in both places and add a test for each. Happy to open a PR.
- 主要语言
- Python
- 星标
- 1.9k
- 派生
- 347
- 平均合并
- 2 天 13 小时
- 30 天内合并 PR
- 20
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
mlco2/codecarbon 的其他 Issue
-
Unit tests on Windows: 13 failures besides the CLI ones in #1459 (one also on any machine with an NVIDIA GPU)可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
mlco2/codecarbon#1460 · 1 条评论 ·
维护者通常 2 天内回复
-
get_cloud_geo_region() returns NaN instead of the city for GCP regions with no state可能已有人在做 @Maduk86 于 3 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 86/100
mlco2/codecarbon#1456 · 1 条评论 · 已指派 1 人 ·
维护者通常 2 天内回复
-
CLI: get_config() returns None without [codecarbon] section; get_api_endpoint() appends api_endpoint under wrong section可能已有人在做 @sohammishra864-wq 于 30 天前认领。 未关闭
难度 2/5 半天 新手友好度 82/100
mlco2/codecarbon#1432 ·
维护者通常 2 天内回复
-
Update the screen shot of the dashboard可能已有人在做 @KLGani 于 5 天前认领。 未关闭documentation good first issue
难度 2/5 1-3 小时 新手友好度 72/100
mlco2/codecarbon#1423 · 5 条评论 ·
维护者通常 2 天内回复
-
Update the bibtex citation可能已有人在做 @davidberenstein1957 于 78 天前认领。 未关闭documentation good first issue
难度 2/5 1-3 小时 新手友好度 68/100
mlco2/codecarbon#1422 · 5 条评论 ·
维护者通常 2 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
-
Validate finite output clamping limits in StepPredictor.prepare_clamping_params to prevent silent NaN/Inf propagation可能已有人在做 @muskan-creates352 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
mllam/neural-lam#848 ·
维护者通常 2 天内回复
-
infra
难度 1/5 1 小时以内 新手友好度 88/100
fab-geocommuns/RNB-coeur#1166 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
deepspeedai/DeepSpeed#8951 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
aws/context-ontology-accelerator#343 ·
维护者通常 1 天内回复