在使用pytorch,使用resnet50训练voc2012数据集时遇到CUDA out of memory的问题!我的显卡是3060ti-8g。
具体错误如下:
RuntimeError: CUDA out of memory. Tried to allocate 30.00 MiB (GPU 0; 8.00 GiB total capacity; 7.22 GiB already allocated; 0 bytes free; 7.32 GiB 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
请各位朋友帮忙看看怎么解决!多谢
通常遇到OOM(out of memory)问题, 只有两种解决方案, 降低您网络训练时的batchsize, 或者选用更小的网络. 看到您这里用的resnet50, 8Gmemory够用了, 您可以将训练时的batchsize减小就可以了, 在训练参数里可调
错误分析:显示GPU可分配的内存不够,我的batch_size = 256
解决方案:改成batch_size=128改成batch_size=64,或者更小