File tree 2 files changed +6
-5
lines changed
pytorch_lightning/trainer/connectors 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -461,6 +461,7 @@ def _set_parallel_devices_and_init_accelerator(self):
461
461
)
462
462
463
463
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
464
465
465
466
def _choose_and_init_cluster_environment (self ):
466
467
self .cluster_environment = LightningEnvironment ()
@@ -484,7 +485,7 @@ def _is_slurm_managing_tasks(self):
484
485
return num_slurm_tasks == total_requested_devices
485
486
486
487
def _choose_strategy (self ):
487
- if self ._accelerator_flag == "ipu_strategy " :
488
+ if self ._accelerator_flag == "ipu " :
488
489
self ._strategy_flag = "ipu_strategy"
489
490
elif self ._accelerator_flag == "tpu" :
490
491
if self ._parallel_devices and len (self ._parallel_devices ) > 1 :
@@ -757,15 +758,15 @@ def devices(self):
757
758
return 0
758
759
759
760
@property
760
- def tpu_cores (self ) -> int :
761
+ def tpu_cores (self ):
761
762
if isinstance (self .accelerator , TPUAccelerator ):
762
- return self .devices
763
+ return self ._tpu_cores
763
764
return 0
764
765
765
766
@property
766
767
def tpu_id (self ) -> Optional [int ]:
767
768
if isinstance (self .accelerator , TPUAccelerator ):
768
- return self .parallel_devices [0 ]
769
+ return self .tpu_cores [0 ]
769
770
return None
770
771
771
772
@property
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ def test_accelerator_selected(tmpdir):
115
115
@RunIf (ipu = True )
116
116
def test_warning_if_ipus_not_used (tmpdir ):
117
117
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" )
119
119
120
120
121
121
@RunIf (ipu = True )
You can’t perform that action at this time.
0 commit comments