It looks like the error message is thrown in the validation loop.
While you are using:
loss = criterion(out, targets.view(n_seqs*n_steps).type(torch.cuda.LongTensor))

in your training loop, you are not creating a CUDA tensor in the validation loop:
val_loss = criterion(out, targets.view(n_seqs*n_steps).type(torch.LongTensor))