def main(argv): args = argument_handler.train_arg_parser(argv) args.lr, args.weight_decay = default_configs.optimisation_params( 'classification', args) # FIXME: cant take more than one GPU args.gpus = args.gpus[0] if 'random_' in args.dataset: args.dataset = args.dataset.replace('random_', '') args.random_labels = True else: args.random_labels = False # TODO: why load weights is False? args.out_dir = prepare_training.prepare_output_directories( dataset_name=args.dataset, network_name=args.network_name, optimiser='sgd', load_weights=False, experiment_name=args.experiment_name, framework='pytorch') if args.seed is not None: random.seed(args.seed) torch.manual_seed(args.seed) cudnn.deterministic = True warnings.warn( 'You have chosen to seed training. ' 'This will turn on the CUDNN deterministic setting, ' 'which can slow down your training considerably! ' 'You may see unexpected behavior when restarting from checkpoints.' ) if args.gpus is not None: warnings.warn( 'You have chosen a specific GPU. This will completely disable data parallelism.' ) if args.dist_url == "env://" and args.world_size == -1: args.world_size = int(os.environ["WORLD_SIZE"]) args.distributed = args.world_size > 1 or args.multiprocessing_distributed json_file_name = os.path.join(args.out_dir, 'args.json') with open(json_file_name, 'w') as fp: json.dump(dict(args._get_kwargs()), fp, sort_keys=True, indent=4) ngpus_per_node = torch.cuda.device_count() if args.multiprocessing_distributed: # Since we have ngpus_per_node processes per node, the total world_size # needs to be adjusted accordingly args.world_size = ngpus_per_node * args.world_size # Use torch.multiprocessing.spawn to launch distributed processes: the # main_worker process function mp.spawn(main_worker, nprocs=ngpus_per_node, args=(ngpus_per_node, args)) else: # Simply call main_worker function main_worker(ngpus_per_node, args)
def main(argv): args = argument_handler.train_arg_parser(argv, extra_args_fun) if args.prediction: from kernelphysiology.dl.utils import augmentation from kernelphysiology.dl.utils import arguments as ah args.manipulation, args.parameters = ah.create_manipulation_list( args.manipulation, args.parameters, augmentation.get_testing_augmentations()) if args.lr is None: args.lr = 0.1 if args.weight_decay is None: args.weight_decay = 1e-4 # FIXME: cant take more than one GPU args.gpus = args.gpus[0] # TODO: why load weights is False? args.out_dir = prepare_training.prepare_output_directories( dataset_name=args.dataset, network_name=args.network_name, optimiser='sgd', load_weights=False, experiment_name=args.experiment_name, framework='pytorch') if args.seed is not None: random.seed(args.seed) torch.manual_seed(args.seed) cudnn.deterministic = True warnings.warn( 'You have chosen to seed training. ' 'This will turn on the CUDNN deterministic setting, ' 'which can slow down your training considerably! ' 'You may see unexpected behavior when restarting from checkpoints.' ) if args.gpus is not None: warnings.warn('You have chosen a specific GPU. This will completely ' 'disable data parallelism.') if args.dist_url == "env://" and args.world_size == -1: args.world_size = int(os.environ["WORLD_SIZE"]) args.distributed = args.world_size > 1 or args.multiprocessing_distributed ngpus_per_node = torch.cuda.device_count() if args.multiprocessing_distributed: # Since we have ngpus_per_node processes per node, the total world_size # needs to be adjusted accordingly args.world_size = ngpus_per_node * args.world_size # Use torch.multiprocessing.spawn to launch distributed processes: the # main_worker process function mp.spawn(main_worker, nprocs=ngpus_per_node, args=(ngpus_per_node, args)) else: # Simply call main_worker function main_worker(ngpus_per_node, args)
def main(argv): args = argument_handler.train_arg_parser(argv, extra_args_fun) args.lr, args.weight_decay = default_configs.optimisation_params( 'classification', args) args.num_classes = 2 # FIXME: cant take more than one GPU args.gpus = args.gpus[0] if args.seed is not None: random.seed(args.seed) torch.manual_seed(args.seed) cudnn.deterministic = True warnings.warn( 'You have chosen to seed training. ' 'This will turn on the CUDNN deterministic setting, ' 'which can slow down your training considerably! ' 'You may see unexpected behavior when restarting from checkpoints.' ) if args.gpus is not None: warnings.warn('You have chosen a specific GPU. This will completely ' 'disable data parallelism.') if args.dist_url == "env://" and args.world_size == -1: args.world_size = int(os.environ["WORLD_SIZE"]) args.distributed = args.world_size > 1 or args.multiprocessing_distributed ngpus_per_node = torch.cuda.device_count() if args.multiprocessing_distributed: # Since we have ngpus_per_node processes per node, the total world_size # needs to be adjusted accordingly args.world_size = ngpus_per_node * args.world_size # Use torch.multiprocessing.spawn to launch distributed processes: the # main_worker process function mp.spawn(main_worker, nprocs=ngpus_per_node, args=(ngpus_per_node, args)) else: # Simply call main_worker function main_worker(ngpus_per_node, args)