{
  "schema_version": "1.0",
  "id": "T-f90a2dcbb2ad",
  "url": "https://gpuatlas.top/articles/T-f90a2dcbb2ad/",
  "title": "batch size 已经是 1 了，还爆显存怎么办？",
  "summary": "batch为1仍OOM先核对微批量含义、实际长样本和失败阶段，再针对权重、激活或更新状态调整。",
  "language": "zh-Hans",
  "category": {
    "id": "c-05",
    "name": "微调与训练",
    "url": "https://gpuatlas.top/categories/c-05/"
  },
  "topics": [],
  "body_text": "batch size为1仍OOM，不表示已经没有可调项。先确认它是每卡微批量，而非全局或其他参数；一个样本可能很长，权重和更新状态也不随batch归零。\n\n查看真实模板、历史与多模态输入，保存最长失败样本和token。缩短后通过只说明长度分支，不应换短数据就宣布原负载修复，回答和监督目标是否被截掉也要检查。\n\n加载失败先看权重、量化与设备映射；前向或反向失败再看激活、长度与受支持重计算；首次更新失败检查可训练范围和优化器。计划LoRA却解冻大量基础参数，会完全改变需求。\n\n梯度累积安排更新前的微步骤，不会让本来放不下的单条输入自动变小。数据切分需保留任务信息，量化、分片和卸载分别有支持及主存通信成本，不能机械全开。\n\n选定一个对应失败阶段的改动后，先完成更新、评估与保存恢复，再把原来的长样本送回去验证。检查它的监督目标是否完整，记录有效token与峰值。若单条仍放不下，再比较较小模型或更合适资源；增加累积或换短数据跑通，都不能代替这条原任务的结果。",
  "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": "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"
    },
    {
      "id": "torch-checkpoint",
      "url": "https://docs.pytorch.org/docs/2.15/checkpoint.html",
      "retrieved_at": "2026-11-25T10:16:15.738480+00:00"
    },
    {
      "id": "peft-quantization",
      "url": "https://raw.githubusercontent.com/huggingface/peft/main/docs/source/developer_guides/quantization.md",
      "retrieved_at": "2026-11-25T09:52:45.997121+00:00"
    }
  ],
  "revision_note": "完善阅读结构；非硬件实测。",
  "representations": {
    "html": "https://gpuatlas.top/articles/T-f90a2dcbb2ad/",
    "json": "https://gpuatlas.top/data/articles/T-f90a2dcbb2ad.json",
    "markdown": "https://gpuatlas.top/data/articles/T-f90a2dcbb2ad.md"
  }
}
