2020-03-19 RuntimeError: CUDA ou

2020-03-20  本文已影响0人  Hie_9e55

GPU跑模型报错
RuntimeError: CUDA out of memory. Tried to allocate 38.00 MiB (GPU 0; 10.76 GiB total capacity; 9.71 GiB already allocated; 5.56 MiB free; 9.82 GiB reserved in total by PyTorch)

  1. GPU还有其他进程占用显存,导致本进程无法分配到足够的显存
  2. 缓存过多,使用torch.cuda.empty_cache()清理缓存
  3. 卡不行,换块显存更大的卡吧
with torch.no_grad():
  # test process

否则会使显存加倍导致OOM错误

上一篇 下一篇

猜你喜欢

热点阅读