|
29 | 29 | from pytorch_lightning.loggers.base import DummyLogger |
30 | 30 | from pytorch_lightning.utilities.exceptions import MisconfigurationException |
31 | 31 | from pytorch_lightning.utilities.parsing import lightning_hasattr, lightning_setattr |
32 | | -from pytorch_lightning.utilities import rank_zero_warn |
33 | | -from pytorch_lightning.utilities.cloud_io import get_filesystem |
34 | 32 |
|
35 | 33 | # check if ipywidgets is installed before importing tqdm.auto |
36 | 34 | # to ensure it won't fail and a progress bar is displayed |
|
43 | 41 | def _run_lr_finder_internally(trainer, model: LightningModule): |
44 | 42 | """ Call lr finder internally during Trainer.fit() """ |
45 | 43 | lr_finder = lr_find(trainer, model) |
46 | | - |
47 | | - if lr_finder is None: |
48 | | - return |
49 | | - |
50 | 44 | lr = lr_finder.suggestion() |
51 | 45 |
|
52 | 46 | # TODO: log lr.results to self.logger |
@@ -136,11 +130,7 @@ def lr_find( |
136 | 130 | trainer.fit(model) |
137 | 131 |
|
138 | 132 | """ |
139 | | - if trainer.fast_dev_run: |
140 | | - rank_zero_warn('Skipping learning rate finder since `fast_dev_run=True`', UserWarning) |
141 | | - return |
142 | | - |
143 | | - save_path = os.path.join(trainer.default_root_dir, 'lr_find_temp_model.ckpt') |
| 133 | + save_path = os.path.join(trainer.default_root_dir, 'lr_find_temp.ckpt') |
144 | 134 |
|
145 | 135 | __lr_finder_dump_params(trainer, model) |
146 | 136 |
|
@@ -191,11 +181,8 @@ def lr_find( |
191 | 181 | lr_finder._total_batch_idx = trainer.total_batch_idx # for debug purpose |
192 | 182 |
|
193 | 183 | # Reset model state |
194 | | - if trainer.is_global_zero: |
195 | | - trainer.checkpoint_connector.restore(str(save_path), on_gpu=trainer.on_gpu) |
196 | | - fs = get_filesystem(str(save_path)) |
197 | | - if fs.exists(save_path): |
198 | | - fs.rm(save_path) |
| 184 | + trainer.checkpoint_connector.restore(str(save_path), on_gpu=trainer.on_gpu) |
| 185 | + os.remove(save_path) |
199 | 186 |
|
200 | 187 | # Finish by resetting variables so trainer is ready to fit model |
201 | 188 | __lr_finder_restore_params(trainer, model) |
|
0 commit comments