spark-memory-thermal-ops
它能做什么
这个工具可以帮你在强大的电脑(DGX Spark)上,于长时间的机器学习任务中管理内存和温度。它能确保你有足够的内存,并防止电脑过热。
适用场景
- ✓在开始长时间任务之前,了解需要多少内存时。
- ✓任务因内存不足而失败时。
- ✓在长时间任务运行期间,监控温度和功耗时。
技能链接
https://github.com/wshobson/agents/blob/main/plugins/dgx-spark-ops/skills/spark-memory-thermal-ops/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“在机器学习任务开始之前,我怎样知道它会占用多少内存?”
每周 5 个新技能,1 分钟读完。
工作原理
它会检查系统可用的总内存,而不仅仅是显卡的显存。它还会监控温度和功耗,防止电脑降速或停止运行。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Spark Memory & Thermal Ops
DGX Spark's GB10 chip has one 128GB unified
memory (UMA) pool shared by CPU and GPU, and a
sustained power ceiling well below its rated
figure. Both break discrete-GPU assumptions:
headroom isn't what nvidia-smi reports, and a
run that starts fast will slow down mid-job
with nothing misconfigured. This skill covers
planning memory headroom, working an actual
OOM, and watching thermals across a long job.
For launch-time failure modes (ABI mismatches,
flash-attn, playbook breakage), see
spark-training-gotchas — this skill assumes
the job starts.
Common Issues Quick Reference
| Situation | Do this |
|---|---|
| Planning headroom before launch | Budget against free -g, not nvidia-smi — see UMA Memory Model |
| Job OOMs on unified memory | Work the OOM Ladder in order: flush, then batch/pack, then method downgrade |
| Throughput drops mid-run | Check the power/temp log before assuming a config bug — see Thermal Monitoring |
| Trainer + inference server both wanted | Run one at a time — see Concurrent Workloads |
When to Use This Skill
- Sizing a training run against the 128GB pool before launch — will this model, method, and batch/pack combination fit.
- A run OOMs mid-load or mid-step and the remediation order matters — what to try first, second, third.
- Watching temperature and power during a multi-hour job, deciding whether a slowdown is thermal throttling or something else.
- Planning to run a trainer alongside an inference server (vLLM, Ollama) on the same box.
UMA Memory Model
Spark has no separate GPU VRAM — the GPU and CPU share one 128GB pool. Two consequences:
nvidia-smiandcudaMemGetInfounderreport pressure — or report nothing at all. Both report CUDA-allocator-visible memory, not the pool's actual state — a box can show headroom innvidia-smiand still OOM, because page-cache and mmap'd pages the allocator doesn't see consume the same pool. On some driver/setups, the memory query returns[N/A], [N/A]outright instead of a number — a script grepping for a numeric value there gets nothing, not a misleading undercount (seespark-training-gotchasgotcha G3).Model load is a transient peak, not the steady state. Loading safetensors weights mmaps the file, then copies into CUDA tensors — for a window during load, both the mmap'd pages and the CUDA copy count against the pool at once. A model that fits while training can still OOM during load if headroom was sized for the post-load footprint instead of this doubled transient.
Plan and diagnose with free -g, not
nvidia-smi:
free -g | awk 'NR==2 {print "free:", $4, "GB"}'
Rule of thumb: take that free figure, subtract a
few GB for OS/driver overhead, and budget against
the result — not the 128GB spec number.
The worksheet in references/uma-accounting.md
accepts parameter count, dtype, and method as
input, and returns a memory estimate to compare
against known anchors.
Planning Sequence
Before launch, work through these in order:
- Read
free -g; subtract OS/driver overhead for the budget. - Estimate weights + optimizer + gradients +
activations from
references/uma-accounting.md. - Compare against the closest anchor (70B QLoRA, 27B LoRA, 9B full FT), not the estimate alone.
- If the estimate is close to the budget, start with shorter packing or a smaller batch — cheaper than hitting the OOM Ladder mid-run.
Example: Sizing a 70B QLoRA Run
A sanity check of the worksheet formula against the ≈40GB anchor:
params = 70e9
weights_gb = params * 0.5 / 1e9 # NF4, step 1
adapter_gb = 0.5 # step 5, negligible
total_gb = weights_gb + adapter_gb # + activations
print(f"{total_gb:.0f}GB before activations")
Weights alone land near the ≈40GB anchor — a plan estimating far above that for the same model class is a signal to recheck dtype and method.
The OOM Ladder
When a job OOMs on unified memory, work this ladder in order. Each step is more disruptive than the last — don't skip ahead: reducing batch size is never step 1.
Flush the buffer cache. Page cache from a previous run or a large dataset read often accounts for GB of the "missing" headroom. This costs nothing but a rerun and doesn't touch the job's configuration:
sync; echo 3 > /proc/sys/vm/drop_cachesNeeds root; a between-run reset, not a
…
常见问题
为什么 `nvidia-smi` 显示的内存不正确?
`nvidia-smi` 只显示程序能够直接使用的内存。在 DGX Spark 上,CPU 和 GPU 共享同一块内存,而系统的其他部分也会占用这块内存,`nvidia-smi` 并不会显示这部分。
我的任务因“OOM”(内存溢出)失败了,该怎么办?
首先,尝试清空内存缓存。如果无效,就减小批次大小(batch size)或序列长度。如果仍然失败,可以考虑使用更简单的训练方法。
为什么我的电脑在长时间任务中会变慢?
这可能是因为过热,也可能是因为电脑达到了功耗上限。这个工具可以帮你监控这些情况,让你知道问题是出在温度上,还是其他原因。
详情
作者的原始描述
Manage unified memory and thermals during long-running ML jobs on NVIDIA DGX Spark. Use when planning memory headroom for a training run on GB10, when a job OOMs on unified memory, or when monitoring temperature and power during multi-hour training.
repo: wshobson/agents
热度
- GitHub 星标
- 41k
- 排名
- #6686
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …