def __init__(self, custom_parser=None): self.version = __version__ logger.info("PyTorch Version {}, Furnace Version {}".format( torch.__version__, self.version)) self.state = State() self.devices = None self.distributed = False if custom_parser is None: self.parser = argparse.ArgumentParser() else: assert isinstance(custom_parser, argparse.ArgumentParser) self.parser = custom_parser self.inject_default_parser() self.args = self.parser.parse_args() self.continue_state_object = self.args.continue_fpath if 'WORLD_SIZE' in os.environ: self.distributed = int(os.environ['WORLD_SIZE']) >= 1 if self.distributed: self.local_rank = self.args.local_rank self.world_size = int(os.environ['WORLD_SIZE']) torch.cuda.set_device(self.local_rank) os.environ['MASTER_PORT'] = self.args.port dist.init_process_group(backend="nccl", init_method='env://') self.devices = [i for i in range(self.world_size)] else: self.devices = parse_devices(self.args.devices)
def __init__(self, custom_parser=None): self.state = State() self.devices = None self.distributed = False if custom_parser is None: self.parser = argparse.ArgumentParser() else: assert isinstance(custom_parser, argparse.ArgumentParser) self.parser = custom_parser self.inject_default_parser() self.args = self.parser.parse_args() self.continue_state_object = self.args.continue_fpath if 'WORLD_SIZE' in os.environ: self.distributed = int(os.environ['WORLD_SIZE']) > 1 if self.distributed: self.local_rank = self.args.local_rank self.world_size = int(os.environ['WORLD_SIZE']) torch.cuda.set_device(self.local_rank) dist.init_process_group(backend="nccl", init_method='env://') self.devices = [i for i in range(self.world_size)] else: self.devices = parse_devices(self.args.devices)
def __init__(self, custom_parser=None): self.version = __version__ logger.info("PyTorch Version {}, Furnace Version {}".format( torch.__version__, self.version)) self.state = State() self.devices = None self.distributed = False if custom_parser is None: self.parser = argparse.ArgumentParser() else: assert isinstance(custom_parser, argparse.ArgumentParser) self.parser = custom_parser self.inject_default_parser() self.args = self.parser.parse_args() self.continue_state_object = self.args.continue_fpath if 'WORLD_SIZE' in os.environ: self.distributed = int(os.environ['WORLD_SIZE']) > 1 self.devices = parse_devices(self.args.devices)
return result_line if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument('-e', '--epochs', default='last', type=str) parser.add_argument('-d', '--devices', default='1', type=str) parser.add_argument('-v', '--verbose', default=False, action='store_true') parser.add_argument('--show_image', '-s', default=False, action='store_true') parser.add_argument('--save_path', '-p', default=None) args = parser.parse_args() all_dev = parse_devices(args.devices) mp_ctx = mp.get_context('spawn') network = CPNet(config.num_classes, criterion=None) data_setting = { 'img_root': config.img_root_folder, 'gt_root': config.gt_root_folder, 'train_source': config.train_source, 'eval_source': config.eval_source } dataset = ADE(data_setting, 'val', None) with torch.no_grad(): segmentor = SegEvaluator(dataset, config.num_classes, config.image_mean, config.image_std, network, config.eval_scale_array, config.eval_flip,