[881]内存不足RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total cap...

原因一:找到错误点,增加以下语句:

with torch.no_grad():

outputs = Net_(inputs) —错误代码的位置。

原因二:GPU没有选对

os.environ[“CUDA_VISIBLE_DEVICES”] = “0, 2, 3”

[881]内存不足RuntimeError: CUDA out of memory. Tried to allocate 16.00 MiB (GPU 0; 2.00 GiB total cap..._第1张图片

查看性能,发现nVidia的只有GPU1,所以改成如下:

os.environ[“CUDA_VISIBLE_DEVICES”] = “0”

若是不能再GPU上跑,直接改成如下:

os.environ[“CUDA_VISIBLE_DEVICES”] = “-1”

不过,这种问题,还是GPU内存不足引起的。应该购买或租用高性能显卡,减少时间的浪费。

来源:https://www.cnblogs.com/yifanrensheng/p/13381931.html
https://blog.csdn.net/pursuit_zhangyu/article/details/88717635

你可能感兴趣的:(异常)