小编Dmi*_*hin的帖子

Pytorch RuntimeError:CUDA 内存不足且有大量可用内存

在训练模型时,我遇到了以下问题:

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

python machine-learning computer-vision pytorch

33
推荐指数
2
解决办法
10万
查看次数