Hello I am new in pytorch but i got this error and i dont know how to fix it…
Warning: Error detected in CudnnRnnBackward. Traceback of forward call that caused the error:
File “D:/GitHubRepos/NLP/biGRU/trainer.py”, line 161, in 
output, loss = train(target, label)
File “D:/GitHubRepos/NLP/biGRU/trainer.py”, line 120, in train
output, hidden = model(target[i], hidden)
File “D:\Python\venv\lib\site-packages\torch\nn\modules\module.py”, line 550, in call
result = self.forward(*input, **kwargs)
File “D:\GitHubRepos\NLP\biGRU\GRU.py”, line 12, in forward
out, h = self.gru(x, h)
File “D:\Python\venv\lib\site-packages\torch\nn\modules\module.py”, line 550, in call
result = self.forward(*input, **kwargs)
File “D:\Python\venv\lib\site-packages\torch\nn\modules\rnn.py”, line 727, in forward
self.dropout, self.training, self.bidirectional, self.batch_first)
(print_stack at …\torch\csrc\autograd\python_anomaly_mode.cpp:60)
Traceback (most recent call last):
File “D:/GitHubRepos/NLP/biGRU/trainer.py”, line 161, in 
output, loss = train(target, label)
File “D:/GitHubRepos/NLP/biGRU/trainer.py”, line 138, in train
loss.backward(retain_graph=True)
File “D:\Python\venv\lib\site-packages\torch\tensor.py”, line 198, in backward
torch.autograd.backward(self, gradient, retain_graph, create_graph)
File “D:\Python\venv\lib\site-packages\torch\autograd_init_.py”, line 100, in backward
allow_unreachable=True)  # allow_unreachable flag
RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [7116, 2372]] is at version 2; expected version 1 instead. Hint: the backtrace further above shows the operation that failed to compute its gradient. The variable in question was changed in there or anywhere later. Good luck!
This is the code of my model.
class GRU(nn.Module):
    def __init__(self, input_size, hidden_size, num_layers):
        super(GRU, self).__init__()
        self.hidden_size = hidden_size
        self.num_layers = num_layers
        self.gru = nn.GRU(input_size, hidden_size, num_layers, batch_first=False)
        self.softmax = nn.Softmax(dim=2)

    def forward(self, x, h):
        out, h = self.gru(x, h)
        out = self.softmax(out)
        return out, h

    def init_hidden(self, batch_size, device):
        weight = next(self.parameters()).data
        hidden = weight.new(self.num_layers, batch_size, self.hidden_size).zero_().to(device)
        return hidden

i think theres something wrong with out, h = self.gru(x, h) but i dont know how to fix it.