Skip to content

Commit

Permalink
condition if tpu_id is None
Browse files Browse the repository at this point in the history
  • Loading branch information
lezwon committed Jun 1, 2020
1 parent 1741fc3 commit 1fb6e58
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pytorch_lightning/trainer/evaluation_loop.py
Expand Up @@ -250,7 +250,7 @@ def _evaluate(self, model: LightningModule, dataloaders, max_batches: int, test_

# on TPU we have to wrap it under the ParallelLoader
if self.use_tpu:
device = xm.xla_device(self.tpu_id)
device = xm.xla_device(self.tpu_id) if self.tpu_id is not None else xm.xla_device()
dataloader = xla_pl.ParallelLoader(dataloader, [device])
dataloader = dataloader.per_device_loader(device)

Expand Down
2 changes: 1 addition & 1 deletion pytorch_lightning/trainer/training_loop.py
Expand Up @@ -413,7 +413,7 @@ def run_training_epoch(self):

# on TPU we have to wrap it under the ParallelLoader
if self.use_tpu:
device = xm.xla_device(self.tpu_id)
device = xm.xla_device(self.tpu_id) if self.tpu_id is not None else xm.xla_device()
train_dataloader = xla_pl.ParallelLoader(train_dataloader, [device])
train_dataloader = train_dataloader.per_device_loader(device)

Expand Down

0 comments on commit 1fb6e58

Please sign in to comment.