RuntimeError: CUDA out of memory. Tried to allocate 320.00 MiB (GPU 0; 10.92 GiB total capacity; 9.9

RuntimeError: CUDA out of memory. Tried to allocate 320.00 MiB (GPU 0; 10.92 GiB total capacity; 9.95 GiB already allocated; 265.38 MiB free; 156.78 MiB cached)

记录一下pytorch中的运行错误以及解决办法,出现如下问题:
在这里插入图片描述
应该是GPU的大小问题,将代码中的batch_size设置小点,我设置的batch_size=128改为batch_size=32就可以运行了。
在这里插入图片描述
具体原因我也不太清楚。。。


版权声明:本文为weixin_42142509原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。