This might be raised, if you are running out of memory.
Check the memory usage via nvidia-smi and try to lower the batch size.
If that’s not the case, disable cudnn via torch.backends.cudnn.enabled = False and rerun the code.
If the code is working fine without cudnn and is not running OOM with cudnn, could you post a code snippet to reproduce this issue as well as your current setup (PyTorch, CUDA, cudnn version and the used hardware)?