Module 'torch.backends.cudnn' has no attribute 'get_handle'

I didn’t find any other meeting the same issue. My cuda and cudnn versions are:
torch.cuda.is_available()
True
torch.version.cuda
‘10.2’
torch.backends.cudnn.is_available()
True
torch.backends.cudnn.version()
7605

When try to train a model with LSTM, I got an error as follow:
File “D:/mlearning/model_code\hydroDL\model\rnn.py”, line 301, in forward
handle = torch.backends.cudnn.get_handle()

File “D:\anaconda3\envs\pytorch-gpu\lib\site-packages\torch\backends_init_.py”, line 47, in getattr
return self.m.getattribute(attr)

AttributeError: module ‘torch.backends.cudnn’ has no attribute ‘get_handle’

Look forward to help.

Many thanks!

Jianduo

torch.backends.cudnn.get_handle() was removed in PyTorch 1.5.0 in this PR so you might need to update your code to be compatible with the latest PyTorch release.

Thanks! But I’m a new user of Python, could I use PyTorch 1.4 instead?

You could downgrade, but I wouldn’t recommend doing so as you might be running into already fixed issues and would miss the latest features.
What’s the use case and why do you need to access the handle?

Hi ptrblck,

Thanks for your help. In fact, I would like to use the code from others who published a paper in Nature Communication. In this paper, they used LSTM to train a model.

Due to the PyTorch version, there are a lot of “no attribute” errors.

I should learn more about the difference between versions of PyTorch now.