{
  "schema_version": "1.0",
  "id": "T-d8dabeffa34d",
  "url": "https://gpuatlas.top/articles/T-d8dabeffa34d/",
  "title": "LLaMA-Factory 训练到保存时才爆显存，怎么排查？",
  "summary": "LLaMA-Factory保存时失败应区分GPU聚合、主存与文件系统，检查点与推理导出也需分别验收。",
  "language": "zh-Hans",
  "category": {
    "id": "c-09",
    "name": "框架配置与故障",
    "url": "https://gpuatlas.top/categories/c-09/"
  },
  "topics": [
    {
      "id": "task-796e01d5af",
      "name": "训练",
      "kind": "task",
      "description": "模型训练时的资源占用与推理不同。查看优化器、激活值、并行策略和中断恢复相关问题。",
      "url": "https://gpuatlas.top/topics/task-796e01d5af/"
    }
  ],
  "body_text": "LLaMA-Factory训练到保存才失败，先看完整错误和产物类型。训练更新通过，不代表收集参数、保存优化器或导出完整权重时没有额外峰值，分片检查点也不一定能直接作为推理模型。\n\n确认保存的是适配器、分片训练状态还是完整导出。某些分片策略在收集特定格式时，会在一个rank、GPU或CPU临时聚合，稳定训练占用不能解释保存全过程。\n\n同时观察每卡、主存和磁盘。GPU OOM、系统内存耗尽、写入空间不足和权限错误是不同问题，不要因为都发生在保存时就降低训练长度；这可能完全没有改变故障阶段。\n\n先用小任务安排一次保存，再用新进程加载恢复训练，检查步数与状态接续；需要推理导出时另外验证。目录出现文件或日志打印成功，都不能代替产物可用性。\n\n完整权重聚合出错时，可按当前实现检查受支持的分片保存或CPU处理路径，同时观察压力是否转到主存和临时磁盘。保留原检查点，用新产物在另一进程中恢复一次；需要推理模型时，再验证导出。确认这些用途都能完成后才整理旧文件，避免训练继续了却丢掉恢复入口。",
  "published_at": null,
  "modified_at": "2026-11-26T15:17:38.690397+00:00",
  "evidence": {
    "type": "documentation_and_conditional_estimates",
    "hardware_tested": false,
    "note": "资料解释与条件估算，非硬件实测。"
  },
  "sources": [
    {
      "id": "llamafactory",
      "url": "https://raw.githubusercontent.com/hiyouga/LLaMA-Factory/main/README.md",
      "retrieved_at": "2026-11-25T09:52:45.997121+00:00"
    },
    {
      "id": "torch-fsdp",
      "url": "https://docs.pytorch.org/docs/2.15/fsdp.html",
      "retrieved_at": "2026-11-25T10:21:36.176985+00:00"
    },
    {
      "id": "deepspeed-zero",
      "url": "https://deepspeed.readthedocs.io/en/latest/zero3.html",
      "retrieved_at": "2026-11-25T10:21:36.176985+00:00"
    },
    {
      "id": "transformers-training-memory",
      "url": "https://raw.githubusercontent.com/huggingface/transformers/main/docs/source/en/model_memory_anatomy.md",
      "retrieved_at": "2026-11-25T10:16:15.738480+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-d8dabeffa34d/",
    "json": "https://gpuatlas.top/data/articles/T-d8dabeffa34d.json",
    "markdown": "https://gpuatlas.top/data/articles/T-d8dabeffa34d.md"
  }
}
