Try adding torch.cuda.synchronize after each cuda operation. That way the error won’t be deferred to later operations.
http://pytorch.org/docs/master/cuda.html#torch.cuda.synchronize 191
If you can share your script, I can take a look.