INNER CODE UNIT · Python
resume
bytedance/byteps · byteps/common/__init__.py:75
def resume(self, num_workers, num_servers, global_rank, context=None):
"""A function that restarts BytePS after being suspended, for elastic training."""
# set DMLC environment variables here
os.environ['DMLC_NUM_WORKER'] = str(num_workers)
os.environ['DMLC_NUM_SERVER'] = str(num_servers)
os.environ['BYTEPS_GLOBAL_RANK'] = str(global_rank)
return self.C_LIB_CTYPES.byteps_resume(num_workers, num_servers)
def size(self):
"""A function that returns the number of BytePS processes.
Returns:
An integer scalar containing the number of BytePS processes.
"""
size = self.C_LIB_CTYPES.byteps_size()
if size == -1:
raise ValueError(
'BytePS has not been initialized; use bps.init().')
return size