From 67528c46658833cadaf3571031be7538c6ce1bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20W=C3=A4lchli?= Date: Tue, 20 Apr 2021 09:34:03 +0200 Subject: [PATCH] Fix attribute error for _gpus_arg_default loading checkpoint prior to 1.2.8 (#7043) --- pytorch_lightning/utilities/argparse.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pytorch_lightning/utilities/argparse.py b/pytorch_lightning/utilities/argparse.py index 5f7c280db8..6dbc4636b9 100644 --- a/pytorch_lightning/utilities/argparse.py +++ b/pytorch_lightning/utilities/argparse.py @@ -286,6 +286,13 @@ def _gpus_allowed_type(x) -> Union[int, str]: return int(x) +def _gpus_arg_default(x) -> Union[int, str]: # pragma: no-cover + # unused, but here for backward compatibility with old checkpoints that need to be able to + # unpickle the function from the checkpoint, as it was not filtered out in versions < 1.2.8 + # see: https://github.com/PyTorchLightning/pytorch-lightning/pull/6898 + pass + + def _int_or_float_type(x) -> Union[int, float]: if '.' in str(x): return float(x)