torch checkpoint 问题记录 使用torch checkpoint时报错:'NoneType' object has no attribute "'detach'"报错地址:site-packages/torch/utils/checkpoints.py报错原因:torch版本较旧,旧版本中checkpoints.py中缺失对Input是否是tensor的判断,导致报错。升级torch版本,可以解决这个问题。报错根本原因:sparse_masks是self.blocks[i] forward函数中的参数,在此处是None
Pytorch节省显存 - checkpoint Pytorch节省显存 - checkpoint官方文档: torch.utils.checkpoint.checkpoint一、查看模型及中间变量的显存占用情况1. 显存占用参考博客:https://oldpan.me/archives/how-to-calculate-gpu-memoryhttps://zhuanlan.zhihu.com/p/31558973主要由两个部分组成:模型参数模型计算产生的中间变量:前向计算过程中,隐层的输出都被保存在显存中。后向梯度计算时,需