johnzbu_2:

The code can work out fine when torch.backends.cudnn.enabled = True , yet the code will miserably face the error when torch.backends.cudnn.enabled = False
and I don’t face the error when I am training CNN.


I assume you are seeing this error, when you enable cudnn, and the code runs without cudnn?
Could you post a dummy input shape to reproduce this issue, please?