diff --git a/pytorch_lightning/models/trainer.py b/pytorch_lightning/models/trainer.py index 8ee004adb3..655316ed3a 100644 --- a/pytorch_lightning/models/trainer.py +++ b/pytorch_lightning/models/trainer.py @@ -363,9 +363,6 @@ class Trainer(TrainerIO): # filter out the weights that were done on gpu so we can load on good old cpus self.optimizers = model.configure_optimizers() - # attach model to DP - model = LightningDataParallel(model, device_ids=self.data_parallel_device_ids) - # run through amp wrapper if self.use_amp: # An example @@ -374,6 +371,9 @@ class Trainer(TrainerIO): ) self.optimizers = optimizers + if self.on_gpu: + model = LightningDataParallel(model, device_ids=self.data_parallel_device_ids) + self.__run_pretrain_routine(model) def ddp_train(self, gpu_nb, model):