pytorch_lightning.trainer.distrib_parts module¶
Root module for all distributed operations in Lightning. Currently supports training on CPU, GPU (dp, ddp, ddp2, horovod) and TPU.
-
class
pytorch_lightning.trainer.distrib_parts.TrainerDPMixin[source]¶ Bases:
abc.ABC-
abstract
call_setup_hook(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
-
abstract
get_model()[source]¶ Warning: this is just empty shell for code implemented in other class.
- Return type
-
abstract
init_optimizers(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
-
abstract
is_function_implemented(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
- Return type
-
abstract
reinit_scheduler_properties(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
-
abstract
run_pretrain_routine(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
-
abstract
setup(*args)[source]¶ Warning: this is just empty shell for code implemented in other class.
- Return type
-
transfer_batch_to_gpu(batch, gpu_id=None)[source]¶ Transfers the data to the GPU.
- Parameters
- Returns
the tensor on the GPU device.
See also
-
abstract
-
pytorch_lightning.trainer.distrib_parts._check_data_type(device_ids)[source]¶ Checks that the device_ids argument is one of: None, Int, String or List. Raises a MisconfigurationException otherwise.
-
pytorch_lightning.trainer.distrib_parts._parse_gpu_ids(gpus)[source]¶ Parses the GPU ids given in the format as accepted by the
Trainer.- Parameters
gpus¶ (
Union[int,str,List[int],None]) – An int -1 or string ‘-1’ indicate that all available GPUs should be used. A list of ints or a string containing list of comma separated integers indicates specific GPUs to use. An int 0 means that no GPUs should be used. Any int N > 0 indicates that GPUs [0..N) should be used.- Return type
- Returns
a list of gpus to be used or
Noneif no GPUs were requested
If no GPUs are available but the value of gpus variable indicates request for GPUs then a MisconfigurationException is raised.
-
pytorch_lightning.trainer.distrib_parts._parse_tpu_cores(tpu_cores)[source]¶ Parses the tpu_cores given in the format as accepted by the
Trainer.- Parameters
tpu_cores¶ (
Union[int,str,List]) – An int 1 or string ‘1’ indicate that 1 core with multi-processing should be used An int 8 or string ‘8’ indicate that all 8 cores with multi-processing should be used A list of int or a string containing list of comma separated integer indicates specific TPU core to use.- Return type
- Returns
a list of tpu_cores to be used or
Noneif no TPU cores were requested
-
pytorch_lightning.trainer.distrib_parts.retry_jittered_backoff(func, num_retries=5, cap_delay=1.0, base_delay=0.01)[source]¶ Retry jittered backoff.
Based on: https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/