Case 1: the versions of CUDA, cudnn, Python and python do not match. Note that the python version, in particular, is easy to ignore.
Case 2 (my case is this): under the condition of case 1, check whether the graphics card used by your program is full, and if it is full, replace the unused card(‘ cuda:3 ’ —> ‘ cuda:0 ’)。
Case 3: add
torch. Backends. Cudnn. Enabled = false in the code