def dist_init(config, dist_device):
    """Distribution Configuration"""
    from . import dist
    dist.init()
    config.DIST.RUN = True
    config.DIST.RANK = dist.rank()
    config.DIST.SIZE = dist.size()
    config.DIST.LOCAL_RANK = dist.local_rank()
    config.DIST.LOCAL_SIZE = dist.local_size()
    config.DIST.ROOT_RANK = 0
    config.DIST.IS_ROOT = config.DIST.RANK == config.DIST.ROOT_RANK
    if dist_device == 'cpu':
        devices = ['cpu' for i in range(config.DIST.LOCAL_SIZE)]
    elif dist_device == 'cuda':
        devices = [('cuda:%d' % i) for i in range(config.DIST.LOCAL_SIZE)]
    else:
        devices = dist_device.split(',')
    config.INFO.DEVICE = devices[config.DIST.LOCAL_RANK]
