espnet2.train.distributed_utils.get_master_addr
Less than 1 minute
espnet2.train.distributed_utils.get_master_addr
espnet2.train.distributed_utils.get_master_addr(prior=None, launcher: str | None = None) → str | None
Retrieve the master address for distributed training.
This function determines the master address based on the provided prior value or by checking the environment variables. If the launcher is set to “slurm”, it will extract the address from the SLURM node list.
- Parameters:
- prior (Optional *[*str ]) – The address to use if provided. If None, the function checks the environment variable MASTER_ADDR.
- launcher (Optional *[*str ]) – The type of launcher used for distributed training (e.g., “slurm”). If “slurm”, it will get the address from the SLURM environment.
- Returns: The master address as a string, or None if it cannot be determined.
- Return type: Optional[str]
- Raises:RuntimeError – If the function is called with “slurm” as the launcher but not within a valid SLURM step.
Examples
>>> # Example usage when not using a launcher
>>> addr = get_master_addr()
>>> print(addr) # Might print the address set in MASTER_ADDR
>>> # Example usage with SLURM launcher
>>> addr = get_master_addr(launcher='slurm')
>>> print(addr) # Prints the master address from SLURM node list