cuDNN version incompatibility with Pytorch

I ran a script and got this error. RuntimeError: expected device cuda:0 but got device cpu

I went through the torch install on the nvidia site and tested it. I got this error…

RuntimeError: cuDNN version incompatibility: PyTorch was compiled against 7500 but linked against 7301

How do I go about fixing this?

Hi vondalej, which version of JetPack and PyTorch are you using?

Are you using one of the pre-built PyTorch pip wheels for Jetson from this post?
https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano-version-1-4-0-now-available/

Also what is the code in the script that throws this error? Thanks.

Yes, I just installed the 1.4 version from that link.

I ran this as validation…

import torch
print('cuDNN version: ’ + str(torch.backends.cudnn.version()))
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.6/dist-packages/torch/backends/cudnn/init.py”, line 83, in version
if _libcudnn() is None:
File “/usr/local/lib/python3.6/dist-packages/torch/backends/cudnn/init.py”, line 76, in _libcudnn
‘but linked against {}’.format(compile_version, __cudnn_version))
RuntimeError: cuDNN version incompatibility: PyTorch was compiled against 7500 but linked against 7301

Hmm, which version of JetPack are you running?

You may want to upgrade your JetPack to the latest (JetPack 4.3), as I built these PyTorch 1.4.0 wheels on JetPack 4.2.1. Otherwise you can build PyTorch from source for your currently-installed version of JetPack.

I’m on 4.2.

That being said I’ve always wanted to update, but do I have to wipe my system or is there a way to do it without re-imaging?

JetPack 4.2 used cuDNN 7.3, JetPack 4.2.1 used cuDNN 7.5, and JetPack 4.3 uses cuDNN 7.6. Since I built these with JetPack 4.2.1, PyTorch is expecting to see cuDNN 7.5 or newer on your system (see this code from PyTorch repo). So I would recommend upgrading to the latest JetPack 4.3, it also comes with a number of other upgrades. JetPack 4.2 was the first version for Nano, so there have been a lot of improvements and fixes since then.

Unfortunately yes (so remember to backup any files you wish to save from your Nano first), however JetPack 4.3 is the last JetPack version that you will need to re-flash/wipe your SD card to upgrade to. Once you are on JetPack 4.3, you will simply be able to upgrade to future JetPack releases from the command line (through apt package manager) without needing to re-flash. However to get onto JetPack 4.3, which is the version that enables this new apt-upgrade mechanism, you still need to re-flash.

Dear vondalej

For JetPack4.2, you can choose the following PyTorch/torchvision versions.

PyTorch v1.0 - torchvision v0.2.2, with being compatible cuDNN7.3.

It works but it is in ‘detached HEAD’ state with regard to git.

Regards,

Mike