【笔记】训练神经网络时解决显存不足的办法:核常兼备,常:减少参数规模;核:减少参数大小

常规方法1:

 常规方法2:

GitHub - gpleiss/efficient_densenet_pytorch: A memory-efficient implementation of DenseNets
model2GitHub - mapillary/inplace_abn: In-Place Activated BatchNorm for Memory-Optimized Training of DNNs

 

 

 

删除loss: Tensor to Variable and memory freeing best practices - #2 by fmassa - PyTorch Forums

降低精度:

https://github.com/NVIDIA/apex

分清楚 eval 和 requires_grad = False

'model.eval()' vs 'with torch.no_grad()' - PyTorch Forums

使用torch.cuda.empty_cache(),在确定的地方释放显存

How can we release GPU memory cache? - PyTorch Forums

核子武器:

    参考资料:

    {
        [1] https://discuss.pytorch.org/t/cuda-memory-continuously-increases-when-net-images-called-in-every-iteration/501

        [2] https://forums.fast.ai/t/clearing-gpu-memory-pytorch/14637/3

        [3] https://pytorch.org/docs/stable/notes/cuda.html#cuda-memory-management

        [4] https://discuss.pytorch.org/t/how-to-debug-causes-of-gpu-memory-leaks/6741/3

    }   

}
 

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值