It’s working with a 1D CPU LongTensor for me:
T, B, C = 100, 10, 4  # longest sequence, batch_size, feature_size
input = torch.randn(T, B, C, device='cuda')
lengths, _ = torch.sort(torch.randint(1, 100, (10,)), descending=True)
print(input.type())
> torch.cuda.FloatTensor
print(lengths.type())
> torch.LongTensor
pack_padded_sequence(input, lengths)

Could you print the type and shape of sorted_n?