sudo apt-get install libcudnn8=${cudnn_version}-1+${cuda_version}
In order to work out what version to install I manually searched for libcudnn8 in
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ 340
for me that was libcudnn8_8.5.0.96-1+cuda11.7_amd64.deb