Palash_Shah:

outputs = outputs.to(device)


I think issue is here, before training loop, send the model to desired device and remove this line. I think transfer to device removes the grad but not sure.
Also, please print the full stack strace so I can find the line and reason behind the error.