barakb:

Assertion t >= 0 && t < n_classes failed.


This is the error message. The target tensor you passed to nll_loss has some out-of-bound class.
You can’t recover from a CUDA device assert failure. This is a CUDA limitation. All you can do is fixing the bug and restart your process.