parser = argparse.ArgumentParser() parser.add_argument('--gpu', '-d', type=str, dest='gpu_ids') parser.add_argument('--continue', '-c', dest='continue_train', action='store_true') parser.add_argument('--debug', dest='debug', action='store_true') parser.add_argument('--batch_size', type=int, dest='batch_size') parser.add_argument('--epoch_size', type=int, dest='epoch_size') parser.add_argument('--num_epochs', type=int, dest='num_epochs') args = parser.parse_args() if not args.gpu_ids: args.gpu_ids = str(np.argmin(mem_info())) if '-' in args.gpu_ids: gpus = args.gpu_ids.split('-') gpus[0] = 0 if not gpus[0].isdigit() else int(gpus[0]) gpus[1] = len( mem_info()) if not gpus[1].isdigit() else int(gpus[1]) + 1 args.gpu_ids = ','.join(map(lambda x: str(x), list(range(*gpus)))) return args args = parse_args() cfg.set_args(args.gpu_ids, args.continue_train, args.batch_size, args.epoch_size, args.num_epochs) trainer = Trainer(Network(), cfg) trainer.train()
def parse_args(): parser = argparse.ArgumentParser() parser.add_argument('--gpu', type=str, dest='gpu_ids') parser.add_argument('--continue', dest='continue_train', action='store_true') args = parser.parse_args() if not args.visatt: if not args.gpu_ids: args.gpu_ids = str(np.argmin(mem_info())) if '-' in args.gpu_ids: gpus = args.gpu_ids.split('-') gpus[0] = 0 if not gpus[0].isdigit() else int(gpus[0]) gpus[1] = len( mem_info()) if not gpus[1].isdigit() else int(gpus[1]) + 1 args.gpu_ids = ','.join(map(lambda x: str(x), list(range(*gpus)))) return args args = parse_args() cfg.set_args(args.gpu_ids, args.continue_train) trainer = Trainer(Model(), cfg) trainer.train()