【E-02】内存不足RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total capacity; 1.34 GiB already allocated; 14.76 MiB free; 1.38 GiB reserved in total by PyTorch)
时间:2020-07-26 23:10:38
收藏:0
阅读:574
原因一:找到错误点,增加以下语句:
with torch.no_grad():
outputs = Net_(inputs) ---错误代码的位置。
? ?
原因二:GPU没有选对
os.environ["CUDA_VISIBLE_DEVICES"] = "0, 2, 3"
查看性能,发现nVidia的只有GPU1,所以改成如下:
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
若是不能再GPU上跑,直接改成如下:
os.environ["CUDA_VISIBLE_DEVICES"] = "-1"
? ?
不过,这种问题,还是GPU内存不足引起的。应该购买或租用高性能显卡,减少时间的浪费。
原文:https://www.cnblogs.com/yifanrensheng/p/13381931.html
评论(0)