赞
踩
在运行以下代码时遇到了内存不足的问题。
- # 代码
- x = self.conv(x)
-
- # 出现以下问题
- RuntimeError: CUDA out of memory. Tried to allocate 66.00 MiB (GPU 0; 2.00 GiB total capacity; 1.21 GiB already allocated; 19.68 MiB free; 1.23 GiB reserved in total by PyTorch)
参考链接:https://blog.csdn.net/pursuit_zhangyu/article/details/88717635、no_grad
将以上代码进行修改,禁止梯度计算来减少内存消耗
- with torch.no_grad():
- x = self.conv(x)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。