Open bolongliu opened 2 years ago
I soved the problem by deleting update_grad param", update_grad=(data_iter_step + 1) % accum_iter == 0" in mae/engine_finetune.py
loss_scaler(loss, optimizer, clip_grad = max_norm,parameters = model.parameters(), create_graph = False, update_grad=(data_iter_step + 1) % accum_iter == 0)
because NativeScaler not have such params
class NativeScaler: state_dict_key = "amp_scaler" def __init__(self): self._scaler = torch.cuda.amp.GradScaler() def __call__(self, loss, optimizer, clip_grad=None, clip_mode='norm', parameters=None, create_graph=False): self._scaler.scale(loss).backward(create_graph=create_graph) if clip_grad is not None: assert parameters is not None self._scaler.unscale_(optimizer) # unscale the gradients of optimizer's assigned params in-place dispatch_clip_grad(parameters, clip_grad, mode=clip_mode) self._scaler.step(optimizer) self._scaler.update() def state_dict(self): return self._scaler.state_dict() def load_state_dict(self, state_dict): self._scaler.load_state_dict(state_dict)
anyone has a solution?
I soved the problem by deleting update_grad param", update_grad=(data_iter_step + 1) % accum_iter == 0" in mae/engine_finetune.py
because NativeScaler not have such params