I removed the DataParallel, and the code worked just fine.
I know that this should not be necessary, but it worked. Since I do not need to train simultaneity in more than one GPU, it is ok for me.
I was already moving from and to cpu and gpu appropriately.
Thank you for the help.