title: RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Int': Pytorch
body: <p>So, I was trying to code a chatbot using Pytorch following this <a href="https://www.youtube.com/watch?v=Da-iHgrmHYg" rel="noreferrer">tutorial</a>.</p>
  <p>Code: (Minimal, Reproducible one)</p>
  <pre><code>tags = []
  for intent in intents['intents']:
      tag = intent['tag']
      tags.append(tag)
  
  tags = sorted(set(tags))
  
  X_train = []
  X_train = np.array(X_train)
  
  class ChatDataset(Dataset):
      def __init__(self):
          self.n_sample = len(X_train)
          self.x_data = X_train
  
  #Hyperparameter
  batch_size = 8
  hidden_size = 47
  output_size = len(tags)
  input_size = len(X_train[0])
  learning_rate = 0.001
  num_epochs = 1000
  
  
  dataset = ChatDataset()
  train_loader = DataLoader(dataset=dataset, batch_size=batch_size, shuffle=True, num_workers=0)
  
  device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') # using gpu
  model = NeuralNet(input_size, hidden_size, output_size).to(device)
  
  # loss and optimizer
  criterion = nn.CrossEntropyLoss()
  optimizer = torch.optim.Adam(model.parameters(), lr=learning_rate)
  
  for epoch in range(num_epochs):
      for (words, labels) in train_loader:
          words = words.to(device)
          labels = labels.to(device)
  
          #forward
          outputs = model(words)
          loss = criterion(outputs, labels) #the line where it is showing the problem
  
          #backward and optimizer step
          optimizer.zero_grad()
          loss.backward()
          optimizer.step()
  
      if (epoch +1) % 100 == 0:
          print(f'epoch {epoch+1}/{num_epochs}, loss={loss.item():.4f}')
  
  print(f'final loss, loss={loss.item():.4f}')
  </code></pre>
  <p><a href="https://gist.github.com/lepotatoguy/7247bbfe80004a699c00150ad6488983" rel="noreferrer">Full Code</a> (if needed)</p>
  <p>I am getting this error while trying to get the loss function.</p>
  <p><code>RuntimeError: &quot;nll_loss_forward_reduce_cuda_kernel_2d_index&quot; not implemented for 'Int'</code></p>
  <p>Traceback:</p>
  <p><code>Traceback (most recent call last): File &quot;train.py&quot;, line 91, in &lt;module&gt; loss = criterion(outputs, labels) File &quot;C:\Users\PC\anaconda3\lib\site-packages\torch\nn\modules\module.py&quot;, line 1102, in _call_impl return forward_call(*input, **kwargs) File &quot;C:\Users\PC\anaconda3\lib\site-packages\torch\nn\modules\loss.py&quot;, line 1150, in forward return F.cross_entropy(input, target, weight=self.weight, File &quot;C:\Users\PC\anaconda3\lib\site-packages\torch\nn\functional.py&quot;, line 2846, in cross_entropy return torch._C._nn.cross_entropy_loss(input, target, weight, _Reduction.get_enum(reduction), ignore_index, label_smoothing) RuntimeError: &quot;nll_loss_forward_reduce_cuda_kernel_2d_index&quot; not implemented for 'Int'</code></p>
  <p>But looking into the tutorial, it seems to work perfectly there whereas it is not in my case.</p>
  <p>What to do now?</p>
  <p>Thanks.</p>