Mrunalini_Ramnath:

I set requires_grad to True and it stopped giving the error but now it doesn’t really train.


This sounds a bit dangerous as I guess you might have set the requires_grad attribute of the loss to True in order to avoid the “no grad error”?
If so, your computation graph would still be detached and you would just mask the error.
Could you post the model definition as well as the loss function, which creates the issue, please?