deepethogram icon indicating copy to clipboard operation
deepethogram copied to clipboard

Lightning Trainer arguments 'reload_dataloaders_every_epoch' and 'progress_bar_refresh_rate' deprecated

Open drbcary opened this issue 3 years ago • 3 comments

[2022-08-10 14:46:36,281] INFO [main.flow_generator_train:63] split: reload: true file: null train_val_test:

  • 0.8
  • 0.2
  • 0.0 compute: fp16: false num_workers: 8 batch_size: 32 min_batch_size: 8 max_batch_size: 512 distributed: false gpu_id: 0 dali: false metrics_workers: 0 reload: overwrite_cfg: false latest: false weights: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\pretrained_models\200221_115158_TinyMotionNet\checkpoint.pt notes: null log: level: info augs: brightness: 0.25 contrast: 0.1 hue: 0.1 saturation: 0.1 color_p: 0.5 grayscale: 0.5 crop_size: null resize:
  • 224
  • 224 dali: false random_resize: false pad: null LR: 0.5 UD: 0.0 degrees: 10 normalization: 'N': 1532006400 mean:
    • 0.5155638358286444
    • 0.5508727163229548
    • 0.5686949595219006 std:
    • 0.0878485417082648
    • 0.07425610385812682
    • 0.07439546025775663 train: lr: 0.0001 scheduler: plateau num_epochs: 10 steps_per_epoch: train: 1000 val: 200 test: 20 min_lr: 5.0e-07 stopping_type: learning_rate milestones:
  • 50
  • 100
  • 150
  • 200
  • 250
  • 300 weight_loss: true patience: 3 early_stopping_begins: 0 viz_metrics: true viz_examples: 10 reduction_factor: 0.1 loss_weight_exp: 1.0 loss_gamma: 1.0 label_smoothing: 0.05 oversampling_exp: 0.0 regularization: style: l2_sp alpha: 1.0e-05 beta: 0.001 flow_generator: type: flow_generator flow_loss: MotionNet flow_max: 10 input_images: 11 flow_sparsity: false smooth_weight_multiplier: 1.0 sparsity_weight: 0.0 loss: MotionNet max: 5 n_rgb: 11 arch: TinyMotionNet weights: pretrained cmap: deepethogram control_arrow_jump: 31 label_view_width: 31 postprocessor: min_bout_length: 1 type: min_bout_per_behavior prediction_opacity: 0.2 project: class_names:
  • background
  • crick_enter
  • pursuit
  • eat config_file: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\project_config.yaml data_path: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\DATA labeler: null model_path: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models name: CricketMouse1 path: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram pretrained_path: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\pretrained_models run: type: train model: flow_generator dir: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\220810_144636_flow_generator_train sequence: filter_length: 15 unlabeled_alpha: 0.1 vertical_arrow_jump: 3

[2022-08-10 14:46:36,408] INFO [main.flow_generator_train:67] Total trainable params: 1,951,784 [2022-08-10 14:46:36,554] INFO [deepethogram.projects.get_weightfile_from_cfg:1068] loading pretrained weights: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\pretrained_models\200221_115158_TinyMotionNet\checkpoint.pt reloading weights... [2022-08-10 14:46:36,556] INFO [deepethogram.utils.load_state:341] loading from checkpoint file D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\pretrained_models\200221_115158_TinyMotionNet\checkpoint.pt... [2022-08-10 14:46:36,585] INFO [main.get_metrics:364] key metric is SSIM [2022-08-10 14:46:36,596] INFO [deepethogram.data.augs.get_gpu_transforms:246] GPU transforms: {'train': Sequential( (0): ToFloat() (1): VideoSequential( (RandomHorizontalFlip_0): RandomHorizontalFlip(RandomHorizontalFlip(p=0.5, p_batch=1.0, same_on_batch=False)) (RandomRotation_1): RandomRotation(RandomRotation(degrees=10, p=0.5, p_batch=1.0, same_on_batch=False, resample=bilinear, align_corners=True)) (ColorJitter_2): ColorJitter(ColorJitter(brightness=0.25, contrast=0.1, saturation=0.1, hue=0.1, p=0.5, p_batch=1.0, same_on_batch=False)) (RandomGrayscale_3): RandomGrayscale(RandomGrayscale(p=0.5, p_batch=1.0, same_on_batch=False)) ) (2): NormalizeVideo() (3): StackClipInChannels() ), 'val': Sequential( (0): ToFloat() (1): NormalizeVideo() (2): StackClipInChannels() ), 'test': Sequential( (0): ToFloat() (1): NormalizeVideo() (2): StackClipInChannels() ), 'denormalize': Sequential( (0): UnstackClip() (1): DenormalizeVideo() )} [2022-08-10 14:46:36,597] INFO [deepethogram.base.init:95] scheduler mode: min [2022-08-10 14:46:36,701] INFO [deepethogram.losses.get_regularization_loss:205] Regularization: L2_SP. Pretrained file: D:\Work\Mouse\deepethogram\CricketMouse1_deepethogram\models\pretrained_models\200221_115158_TinyMotionNet\checkpoint.pt alpha: 1e-05 beta: 0.001 [2022-08-10 14:46:36,726] INFO [deepethogram.flow_generator.losses.init:179] Using MotionNet Loss with settings: smooth_weights: [0.01, 0.02, 0.04, 0.08, 0.16] flow_sparsity: False sparsity_weight: 0.0 Traceback (most recent call last): File "C:\Users\bcary.conda\envs\deg\lib\site-packages\deepethogram\base.py", line 398, in get_trainer_from_cfg log_every_n_steps=1) File "C:\Users\bcary.conda\envs\deg\lib\site-packages\pytorch_lightning\utilities\argparse.py", line 345, in insert_env_defaults return fn(self, **kwargs) TypeError: init() got an unexpected keyword argument 'reload_dataloaders_every_epoch'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\bcary.conda\envs\deg\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Users\bcary.conda\envs\deg\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\bcary.conda\envs\deg\lib\site-packages\deepethogram\flow_generator\train.py", line 374, in flow_generator_train(cfg) File "C:\Users\bcary.conda\envs\deg\lib\site-packages\deepethogram\flow_generator\train.py", line 78, in flow_generator_train trainer = get_trainer_from_cfg(cfg, lightning_module, stopper) File "C:\Users\bcary.conda\envs\deg\lib\site-packages\deepethogram\base.py", line 413, in get_trainer_from_cfg log_every_n_steps=1) File "C:\Users\bcary.conda\envs\deg\lib\site-packages\pytorch_lightning\utilities\argparse.py", line 345, in insert_env_defaults return fn(self, **kwargs) TypeError: init() got an unexpected keyword argument 'progress_bar_refresh_rate'

drbcary avatar Aug 10 '22 19:08 drbcary

Got the same error. Any idea what is happening @jbohnslav ?

hummuscience avatar Sep 05 '22 12:09 hummuscience

The most recent Pytorch Lightning Trainer does not support progress_bar_refresh_rate

commented out the two lines using the argument in https://github.com/jbohnslav/deepethogram/blob/master/deepethogram/base.py and ended up with the following error:

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py in _fit_impl(self, model, train_dataloaders, val_dataloaders, datamodule, ckpt_path)
    739             ckpt_path, model_provided=True, model_connected=self.lightning_module is not None
    740         )
--> 741         results = self._run(model, ckpt_path=self.ckpt_path)
    742 
    743         assert self.state.stopped

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py in _run(self, model, ckpt_path)
   1164         self._checkpoint_connector.resume_end()
   1165 
-> 1166         results = self._run_stage()
   1167 
   1168         log.detail(f"{self.__class__.__name__}: trainer tearing down")

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py in _run_stage(self)
   1250         if self.predicting:
   1251             return self._run_predict()
-> 1252         return self._run_train()
   1253 
   1254     def _pre_training_routine(self):

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py in _run_train(self)
   1280         self.fit_loop.trainer = self
   1281         with torch.autograd.set_detect_anomaly(self._detect_anomaly):
-> 1282             self.fit_loop.run()
   1283 
   1284     def _run_evaluate(self) -> _EVALUATE_OUTPUT:

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py in run(self, *args, **kwargs)
    198             try:
    199                 self.on_advance_start(*args, **kwargs)
--> 200                 self.advance(*args, **kwargs)
    201                 self.on_advance_end()
    202                 self._restarting = False

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/loops/fit_loop.py in advance(self)
    267         )
    268         with self.trainer.profiler.profile("run_training_epoch"):
--> 269             self._outputs = self.epoch_loop.run(self._data_fetcher)
    270 
    271     def on_advance_end(self) -> None:

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/loops/loop.py in run(self, *args, **kwargs)
    198             try:
    199                 self.on_advance_start(*args, **kwargs)
--> 200                 self.advance(*args, **kwargs)
    201                 self.on_advance_end()
    202                 self._restarting = False

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/loops/epoch/training_epoch_loop.py in advance(self, data_fetcher)
    191 
    192             # hook
--> 193             self.trainer._call_callback_hooks("on_train_batch_start", batch, batch_idx)
    194             response = self.trainer._call_lightning_module_hook("on_train_batch_start", batch, batch_idx)
    195             self.trainer._call_strategy_hook("on_train_batch_start", batch, batch_idx)

~/.conda/envs_ppc/deg/lib/python3.7/site-packages/pytorch_lightning/trainer/trainer.py in _call_callback_hooks(self, hook_name, *args, **kwargs)
   1594             if callable(fn):
   1595                 with self.profiler.profile(f"[Callback]{callback.state_key}.{hook_name}"):
-> 1596                     fn(self, self.lightning_module, *args, **kwargs)
   1597 
   1598         if pl_module:

TypeError: on_train_batch_start() missing 1 required positional argument: 'dataloader_idx'

hummuscience avatar Sep 05 '22 12:09 hummuscience

downgrading pytorch lightning to 1.6.5 with pip install pytorch_lightning==1.6.5 solves this issue

hummuscience avatar Sep 05 '22 14:09 hummuscience