Two options:

You can override cuDNN paths and change ENV to use a local copy of newer cuDNN 7.
Or,
Use a Docker container from NVidia to build your PyTorch inside it.  You can find latest containers here: https://hub.docker.com/r/nvidia/cuda/tags/ 7