As described in the docs for nn.CrossEntropyLoss, the target should use class indices and be a LongTensor.
Here is a small example for 5 classes:
batch_size = 10
nb_classes = 5

output = torch.randn(batch_size, nb_classes, requires_grad=True) # your model output
target = torch.randint(0, nb_classes, (batch_size,))
print(target)
> tensor([1, 4, 2, 2, 2, 0, 2, 1, 3, 3])

criterion = nn.CrossEntropyLoss()
loss = criterion(output, target)

If you are passing one-hot encoded targets, the criterion should raise an error, since your target tensor should have two dimensions in the one-hot version.
Could you check your current target and make sure it contains the expected values in the expected shape?