espnet2.train.distributed_utils.get_master_port
Less than 1 minute
espnet2.train.distributed_utils.get_master_port
espnet2.train.distributed_utils.get_master_port(prior=None) → int | None
Get the master port for distributed training.
This function retrieves the master port to be used in a distributed training setup. If a prior value is provided, it will be returned; otherwise, the function checks the environment variable MASTER_PORT. If MASTER_PORT is not set, it returns None.
- Parameters:
- prior (Optional *[*int ]) – The prior port value. If not provided, the function
- variable. (will look for the MASTER_PORT environment)
- Returns: The master port if it is provided or found in the environment, otherwise None.
- Return type: Optional[int]
Examples
>>> # Assuming the environment variable is set
>>> os.environ["MASTER_PORT"] = "12345"
>>> get_master_port() # Returns 12345
>>> # Without prior value and no environment variable set
>>> get_master_port() # Returns None
>>> # With a prior value
>>> get_master_port(8080) # Returns 8080