The doc 78 explains, that input should have dimensions [minibatch, C], where C is the number of classes.
In you example you seem to have a batch_size of 3 for the target and only one predicion.
Try the following code:
batch_size = 3
a = Variable(torch.LongTensor(batch_size).random_(5))
b = Variable(torch.randn(batch_size, 5))

criterion = nn.CrossEntropyLoss()
loss = criterion(b, a)