pl verify if your inputs to the loss function is of appropriate sizes.
Just a simple working example:
import torch, torch.nn as nn

logits = torch.randn(10, 5)     # [10 x 5]
target = torch.randint(0, 4, [10])    # [10]   
loss = nn.CrossEntropyLoss()                            
loss_value = loss(logits, target)  # input: ([10 x 5], [10] ). All class labels are from 0 to 4.


RuntimeError: Assertion `cur_target >= 0 && cur_target < n_classes’ failed. at /Users/administrator/nightlies/pytorch-1.0.0/wheel_build_dirs/conda_3.7/conda/conda-bld/pytorch_1544144746443/work/aten/src/THNN/generic/ClassNLLCriterion.c:93

this error happens if the class labels are not within the range. (from 0 to number of classes)