added warning to crash (#1625)

* added warning to crash

* formatting

Co-authored-by: J. Borovec <jirka.borovec@seznam.cz>
This commit is contained in:
William Falcon
2020-04-30 08:04:18 -04:00
committed by GitHub
co-authored by J. Borovec
parent 2ec8d61e94
commit d40425d257
3 changed files with 10 additions and 5 deletions
+3 -3
View File
@@ -1162,9 +1162,9 @@ class LightningModule(ABC, GradInformation, ModelIO, ModelHooks):
# native amp + lbfgs is a no go right now
if self.trainer.use_amp and self.trainer.use_native_amp:
m = 'native PyTorch amp and lbfgs are not compatible. To request, please file' \
'a Github issue in PyTorch and tag @mcarilli'
raise MisconfigurationException(m)
raise MisconfigurationException(
'native PyTorch amp and lbfgs are not compatible.'
' To request, please file a Github issue in PyTorch and tag @mcarilli')
optimizer.step(second_order_closure)
else:
if self.trainer.use_amp and self.trainer.use_native_amp:
+6 -2
View File
@@ -251,9 +251,11 @@ class TrainerIOMixin(ABC):
# do the actual save
try:
self._atomic_save(checkpoint, filepath)
except AttributeError:
except AttributeError as e:
if 'hparams' in checkpoint:
del checkpoint['hparams']
rank_zero_warn('warning, `hparams` dropped from checkpoint.'
f' An attribute is not picklable {e}')
self._atomic_save(checkpoint, filepath)
@@ -434,9 +436,11 @@ class TrainerIOMixin(ABC):
# TODO: fix for anything with multiprocess DP, DDP, DDP2
try:
self._atomic_save(checkpoint, filepath)
except AttributeError:
except AttributeError as e:
if 'hparams' in checkpoint:
del checkpoint['hparams']
rank_zero_warn('warning, `hparams` dropped from checkpoint.'
f' An attribute is not picklable {e}')
self._atomic_save(checkpoint, filepath)
+1
View File
@@ -18,6 +18,7 @@ exclude_lines =
pragma: no-cover
warnings
pass
rank_zero_warn
[flake8]
# TODO: this should be 88 or 100 according PEP8