espnet2.train.distributed_utils.is_in_slurm_step
Less than 1 minute
espnet2.train.distributed_utils.is_in_slurm_step
espnet2.train.distributed_utils.is_in_slurm_step() → bool
Check if the current process is running in a SLURM step.
This function verifies whether the current process is part of a SLURM job step by checking the presence of specific environment variables related to SLURM. It returns True if the process is indeed in a SLURM step, and False otherwise.
- Returns: True if the process is in a SLURM step, False otherwise.
- Return type: bool
Examples
>>> os.environ['SLURM_PROCID'] = '0'
>>> os.environ['SLURM_NTASKS'] = '2'
>>> os.environ['SLURM_STEP_NUM_NODES'] = '1'
>>> os.environ['SLURM_STEP_NODELIST'] = 'node[1-2]'
>>> is_in_slurm_step()
True
>>> del os.environ['SLURM_STEP_NUM_NODES']
>>> is_in_slurm_step()
False