You might want to upgrade your pytorch version to get a more useful error message.
The doc is here 8, but you can simply add at the beginning of your file (before the forward pass) torch.autograd.set_detect_anomaly(True).