Skip to content

Commit 2134c3b

Browse files
committed
fix typo
1 parent c2c3ab0 commit 2134c3b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

pytorch_lightning/trainer/connectors/accelerator_connector.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ def _set_parallel_devices_and_init_accelerator(self):
461461
)
462462

463463
self._gpus = self._device_flag if not self._gpus else self._gpus
464+
self._tpu_cores = self._device_flag if not self._tpu_cores else self._tpu_cores
464465

465466
def _choose_and_init_cluster_environment(self):
466467
self.cluster_environment = LightningEnvironment()
@@ -484,7 +485,7 @@ def _is_slurm_managing_tasks(self):
484485
return num_slurm_tasks == total_requested_devices
485486

486487
def _choose_strategy(self):
487-
if self._accelerator_flag == "ipu_strategy":
488+
if self._accelerator_flag == "ipu":
488489
self._strategy_flag = "ipu_strategy"
489490
elif self._accelerator_flag == "tpu":
490491
if self._parallel_devices and len(self._parallel_devices) > 1:
@@ -757,15 +758,15 @@ def devices(self):
757758
return 0
758759

759760
@property
760-
def tpu_cores(self) -> int:
761+
def tpu_cores(self):
761762
if isinstance(self.accelerator, TPUAccelerator):
762-
return self.devices
763+
return self._tpu_cores
763764
return 0
764765

765766
@property
766767
def tpu_id(self) -> Optional[int]:
767768
if isinstance(self.accelerator, TPUAccelerator):
768-
return self.parallel_devices[0]
769+
return self.tpu_cores[0]
769770
return None
770771

771772
@property

tests/accelerators/test_ipu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def test_accelerator_selected(tmpdir):
115115
@RunIf(ipu=True)
116116
def test_warning_if_ipus_not_used(tmpdir):
117117
with pytest.warns(UserWarning, match="IPU available but not used. Set the `ipus` flag in your trainer"):
118-
Trainer(default_root_dir=tmpdir)
118+
Trainer(default_root_dir=tmpdir, accelerator="cpu")
119119

120120

121121
@RunIf(ipu=True)

0 commit comments

Comments
 (0)