Distributed launchers
Launchers
Functions for launching training on distributed processes.
accelerate.notebook_launcher
( functionargs = ()num_processes = Nonemixed_precision = 'no'use_port = '29500'master_addr = '127.0.0.1'node_rank = 0num_nodes = 1 )
Parameters
function (
Callable
) โ The training function to execute. If it accepts arguments, the first argument should be the index of the process run.args (
Tuple
) โ Tuple of arguments to pass to the function (it will receive*args
).num_processes (
int
, optional) โ The number of processes to use for training. Will default to 8 in Colab/Kaggle if a TPU is available, to the number of GPUs available otherwise.mixed_precision (
str
, optional, defaults to"no"
) โ Iffp16
orbf16
, will use mixed precision training on multi-GPU.use_port (
str
, optional, defaults to"29500"
) โ The port to use to communicate between processes when launching a multi-GPU training.master_addr (
str
, optional, defaults to"127.0.0.1"
) โ The address to use for communication between processes.node_rank (
int
, optional, defaults to 0) โ The rank of the current node.num_nodes (
int
, optional, defaults to 1) โ The number of nodes to use for training.
Launches a training function, using several processes or multiple nodes if itโs possible in the current environment (TPU with multiple cores for instance).
To use this function absolutely zero calls to a CUDA device must be made in the notebook session before calling. If any have been made, you will need to restart the notebook and make sure no cells use any CUDA capability.
Setting ACCELERATE_DEBUG_MODE="1"
in your environment will run a test before truly launching to ensure that none of those calls have been made.
Example:
Copied
accelerate.debug_launcher
( functionargs = ()num_processes = 2 )
Parameters
function (
Callable
) โ The training function to execute.args (
Tuple
) โ Tuple of arguments to pass to the function (it will receive*args
).num_processes (
int
, optional, defaults to 2) โ The number of processes to use for training.
Launches a training function using several processes on CPU for debugging purposes.
This function is provided for internal testing and debugging, but itโs not intended for real trainings. It will only use the CPU.
Last updated