训练出错: CUDA out of memory.
Tried to allocate 32.00 MiB (GPU 0; 4.00 GiB total capacity; 3.46 GiB already allocated; 0 bytes free; 3.50 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
解决方案:
这是因为显存超出了电脑的显卡大小了,把批次大小调小即可;如果已经调整为2了还是不行,那就参考这个视频的调整电脑虚拟内存部分:https://www.bilibili.com/video/BV1Ns4y1M7Qw/










