Could you run the code with CUDA_LAUNCH_BLOCKING=1 python scrit.py and post the stack trace here?
The current error message might point to a wrong line of code.
Also, could you post the arguments and shapes of all layers and tensors, so that we could reproduce this issue?