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就可以运行了。
在这里插入图片描述
具体原因我也不太清楚。。。

猜你喜欢

转载自blog.csdn.net/weixin_42142509/article/details/111937217