在训练模型时,我遇到了以下问题:
RuntimeError: CUDA out of memory. Tried to allocate 304.00 MiB (GPU 0; 8.00 GiB total capacity; 142.76 MiB already allocated; 6.32 GiB free; 158.00 MiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
正如我们所看到的,当尝试分配 304 MiB 内存时发生错误,而 6.32 GiB 是空闲的!问题是什么?正如我所看到的,建议的选项是设置 max_split_size_mb 以避免碎片。它会有帮助吗?如何正确地做到这一点?
这是我的 PyTorch 版本:
火炬==1.10.2+cu113
火炬视觉==0.11.3+cu113
火炬音频===0.10.2+cu113
我浪费了几个小时,直到我发现减少batch size
并调整输入图像的宽度(image size
)是必要的步骤。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)