def pl_train_with_tune(cfg, pl_module_cls, checkpoint_dir=None): cfg = munch_to_dictconfig(Munch(cfg)) checkpoint_path = (None if not checkpoint_dir else os.path.join( checkpoint_dir, f"{pl_module_cls.__name__}.ckpt")) trainer_extra_args = dict(gpus=1 if cfg.gpu else None, progress_bar_refresh_rate=0, resume_from_checkpoint=checkpoint_path, callbacks=[TuneReportCheckpointCallback()]) pl_train(cfg, pl_module_cls, **trainer_extra_args)
def main(cfg: OmegaConf): with StdoutTee('train.stdout'), StderrTee('train.stderr'): print(OmegaConf.to_yaml(cfg)) pl_module_cls = DistillLightningModel if cfg.train.get( 'crossfit_size', 1) == 1 else DistillCrossfitLightningModel if cfg.runner.name == 'pl': pl_train(cfg, pl_module_cls) else: assert cfg.runner.name == 'ray', 'Only pl and ray runners are supported' # Shouldn't need to install ray unless doing distributed training from ray_runner import ray_train ray_train(cfg, pl_module_cls)
def main(cfg: OmegaConf): with StdoutTee('train.stdout'), StderrTee('train.stderr'): print(OmegaConf.to_yaml(cfg)) if cfg.runner.name == 'pl': trainer, model = pl_train(cfg, LightningModel) else: assert cfg.runner.name == 'ray', 'Only pl and ray runners are supported' # Shouldn't need to install ray unless doing distributed training from ray_runner import ray_train ray_train(cfg, LightningModel)
def main(cfg: OmegaConf): print(cfg.pretty()) if cfg.runner.name == 'pl': from pl_runner import pl_train trainer, model = pl_train(cfg, RNNTraining) elif cfg.runner.name == 'ray': # Shouldn't need to install ray unless doing distributed training from ray_runner import ray_train ray_train(cfg, RNNTraining) else: assert False, 'Only pl and ray runners are supported'
def main(cfg: OmegaConf): # We want to add fields to cfg so need to call OmegaConf.set_struct OmegaConf.set_struct(cfg, False) print(OmegaConf.to_yaml(cfg)) if cfg.runner.name == 'pl': from pl_runner import pl_train trainer, model = pl_train(cfg, RNNTraining) elif cfg.runner.name == 'ray': # Shouldn't need to install ray unless doing distributed training from ray_runner import ray_train ray_train(cfg, RNNTraining) else: assert False, 'Only pl and ray runners are supported'