Skip to content

Commit

Permalink
Update tpu_spawn.py
Browse files Browse the repository at this point in the history
  • Loading branch information
four4fish authored Dec 1, 2021
1 parent 4c8ba27 commit 0a68c41
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pytorch_lightning/plugins/training_type/tpu_spawn.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,9 @@ def _move_optimizer_state(self, device: Optional[torch.device] = None) -> None:
"""Moves the state of the optimizers to the TPU if needed."""
# TODO: `self.root_device` would raise error if called outside the spawn process
# while training on 8 and more cores.
if device:
raise ValueError(f"device should be None" f" found: {device}.")
device = device or self.root_device
for opt in self.optimizers:
for p, v in opt.state.items():
opt.state[p] = apply_to_collection(v, torch.Tensor, move_data_to_device, device)
opt.state[p] = apply_to_collection(v, torch.Tensor, move_data_to_device, device or self.root_device)

def _setup_model(self, model: Module) -> Module:
return model
Expand Down

0 comments on commit 0a68c41

Please sign in to comment.