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中的运行错误以及解决办法,出现如下问题:
RuntimeError: CUDA out of memory. Tried to allocate 320.00 MiB (GPU 0; 10.92 GiB total capacity; 9.9_第1张图片
应该是GPU的大小问题,将代码中的batch_size设置小点,我设置的batch_size=128改为batch_size=32就可以运行了。
RuntimeError: CUDA out of memory. Tried to allocate 320.00 MiB (GPU 0; 10.92 GiB total capacity; 9.9_第2张图片
具体原因我也不太清楚。。。

你可能感兴趣的:(pytorch,机器学习,深度学习,pytorch)