Thanks for the information.
Could you check that all targets are in the range [0, nb_classes-1].
The stack trace points to nll_loss which probably raises an out of bounds error.
If you run the code on the CPU, the error message should be better and I guess pointing to the out of bounds error.