RuntimeError: CUDA out of memory.

报错:

RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 10.76 GiB total capacity; 9.04 GiB already allocated; 28.38 MiB free; 9.04 GiB reserved in total by PyTorch)

报错解释:

(原创、不是重复文章)xxx GiB reserved in total by PyTorch的问题_刹不死_subs的博客-CSDN博客

1、减小batch可减小显存占用

2、验证和测试的时候记得加上

with torch.no_grad():

你可能感兴趣的:(报错整理,机器学习)