Seems like your labels and outputs are on different GPUs. Move them to the same GPU and it should work. Something like:
output = model(data)
target = target.to(output.device)
loss = F.nll_loss(output, target)
loss.backward()