报错文本结构(示意)
报错文本结构(示意)
CUDA out of memory. Tried to allocate 2.34 GiB.
GPU 0 has a total capacity of 79.65 GiB of which 1.98 GiB is free.
77.50 GiB is allocated ... 77.56 GiB is reserved ...
64.00 MiB is reserved by PyTorch but unallocated| allocated | 当前活跃张量占用 |
|---|---|
| reserved | 分配器向驱动保留的总量,含缓存块 |
| free | 驱动层面仍可分配的量 |
| reserved but unallocated | 缓存块;数值大且申请失败=碎片信号 |
碎片缓解(先在预发验证)
碎片缓解(先在预发验证)
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:Trueexpandable_segments 的兼容性随 CUDA 与框架版本而异:确认本环境支持后再用于生产。