I am running this script in the docker container. The  docker image was built from

nvidia/cuda:10.2-cudnn7-devel-ubuntu18.04

The cuda version for both the pytorch and docker environment is 10.2.
I still get the same cudnn error and crash.