Well, if your models fit on one GPU, DataParallel should work.
Your code seems to be a bit strange (net output is loss), but since this seems to be just an example, I hope to get the idea.
Could you create a code example reproducing the initial error?