Oh I haven’t seen you’ve added the code.
I’ll try to reproduce it on my machine.
EDIT:
I can reproduce the error with the exception: free(): invalid next size (normal) in Variable._execution_engine.run_backward().
EDIT2:
The code runs fine on CPU, so it seems to be related to some CUDA functions.