You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Essentially whenever I calculate the sinkhorn loss, pytorch's internal gradient tracking turns back on.
I believe this is to do with line 280 in geomloss/sinkhorn_divergence.py: torch.autograd.set_grad_enabled(True)
This is obviously not an issue during training, but it is causing my memory to explode during inference or validation as the gradients are not cleared as there typically is no backwards pass.
I think this could be fixed by using something like: cur_grad_status = torch.is_grad_enabled() ## At beginning of sinkhorn_loop() torch.autograd.set_grad_enabled(cur_grad_status) ## At end of sinkhorn_loop()
The text was updated successfully, but these errors were encountered:
@jeanfeydy I just spent an hour or so coming to the same conclusion as to why I'm running out of memory during testing too. Looks like this PR would be a straight forward fix. Any chance you could merge it in? Thanks!
Essentially whenever I calculate the sinkhorn loss, pytorch's internal gradient tracking turns back on.
I believe this is to do with line 280 in geomloss/sinkhorn_divergence.py:
torch.autograd.set_grad_enabled(True)
This is obviously not an issue during training, but it is causing my memory to explode during inference or validation as the gradients are not cleared as there typically is no backwards pass.
I think this could be fixed by using something like:
cur_grad_status = torch.is_grad_enabled() ## At beginning of sinkhorn_loop()
torch.autograd.set_grad_enabled(cur_grad_status) ## At end of sinkhorn_loop()
The text was updated successfully, but these errors were encountered: