Python报错:RuntimeError: CUDA out of memory. Tried to allocate 48.00 MiB

Python报错:RuntimeError: CUDA out of memory. Tried to allocate 48.00 MiB (GPU 0; 6.00 GiB total capacity; 4.44 GiB already allocated; 0 bytes free; 4.49 GiB reserved in total by PyTorch)
在这里插入图片描述
可以修改batch_size大小进行解决,例如我是将batch_size = 128改为32即可。
在这里插入图片描述
但是这种处理方式也是设备硬伤而折中的办法,因为batch_size缩小有可能影响模型的最终性能。

你可能感兴趣的:(Python常见报错,python,其他,经验分享)