I assume your target is an image with the class index at each pixel.
Try to cast it to a LongTensor, before calculating the loss.
Here is a simple example:
x = Variable(torch.FloatTensor(1, 10, 10, 10).random_())
y = Variable(torch.FloatTensor(1, 10, 10).random_(0, 10))

criterion = nn.NLLLoss2d()

loss = criterion(F.log_softmax(x), y.long())

You could of course just try to load your target as a long array beforehand.