Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'DataModule' object has no attribute 'has_teardown_None' #7286

Closed
awaelchli opened this issue Apr 29, 2021 · 6 comments · Fixed by #7173
Closed

AttributeError: 'DataModule' object has no attribute 'has_teardown_None' #7286

awaelchli opened this issue Apr 29, 2021 · 6 comments · Fixed by #7173
Assignees
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Milestone

Comments

@awaelchli
Copy link
Contributor

awaelchli commented Apr 29, 2021

🐛 Bug

AttributeError: 'DataModule' object has no attribute 'has_teardown_None'

Happens when Ctrl+C a GPU training script.

Please reproduce using the BoringModel

To Reproduce

  1. git checkout b6706470c1e7a1db47f5dc2440fe3b970bdf209c (current master)
  2. python pl_examples/basic_examples/simple_image_classifier.py --trainer.gpus 1
  3. press Ctrl+C

Error:

^C/home/adrian/repositories/pytorch-lightning/pytorch_lightning/utilities/distributed.py:69: UserWarning: Detected KeyboardInterrupt, attempting graceful shutdown...
  warnings.warn(*args, **kwargs)
Traceback (most recent call last):
  File "pl_examples/basic_examples/simple_image_classifier.py", line 86, in <module>
    cli_main()
  File "pl_examples/basic_examples/simple_image_classifier.py", line 79, in cli_main
    cli = LightningCLI(LitClassifier, MNISTDataModule, seed_everything_default=1234)
  File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 174, in __init__
    self.fit()
  File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 264, in fit
    self.trainer.fit(**self.fit_kwargs)
  File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/trainer/trainer.py", line 858, in fit
    self._launch(model, train_dataloader=train_dataloader, val_dataloaders=val_dataloaders, datamodule=datamodule)
  File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/trainer/trainer.py", line 494, in _launch
    self.call_teardown_hook(model)
  File "/home/adrian/repositories/pytorch-lightning/pytorch_lightning/trainer/trainer.py", line 1141, in call_teardown_hook
    called = getattr(self.datamodule, f'has_teardown_{state}')
AttributeError: 'MNISTDataModule' object has no attribute 'has_teardown_None'
Exception ignored in: <function tqdm.__del__ at 0x7f4b56365a60>
Traceback (most recent call last):
  File "/home/adrian/anaconda3/envs/pl/lib/python3.8/site-packages/tqdm/std.py", line 1145, in __del__
  File "/home/adrian/anaconda3/envs/pl/lib/python3.8/site-packages/tqdm/std.py", line 1299, in close
  File "/home/adrian/anaconda3/envs/pl/lib/python3.8/site-packages/tqdm/std.py", line 1492, in display
  File "/home/adrian/anaconda3/envs/pl/lib/python3.8/site-packages/tqdm/std.py", line 1148, in __str__
  File "/home/adrian/anaconda3/envs/pl/lib/python3.8/site-packages/tqdm/std.py", line 1450, in format_dict
TypeError: cannot unpack non-iterable NoneType object

Expected behavior

No error.

Environment

  • CUDA:
    - GPU:
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - GeForce RTX 3090
    - available: True
    - version: 11.1
  • Packages:
    - numpy: 1.20.2
    - pyTorch_debug: False
    - pyTorch_version: 1.8.1+cu111
    - pytorch-lightning: 1.3.0rc2
    - tqdm: 4.60.0
  • System:
    - OS: Linux
    - architecture:
    - 64bit
    - ELF
    - processor: x86_64
    - python: 3.8.8
    - version: added test model to do also #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020
@awaelchli awaelchli added bug Something isn't working help wanted Open to be worked on labels Apr 29, 2021
@awaelchli awaelchli self-assigned this Apr 29, 2021
@ananthsub
Copy link
Contributor

I think @carmocca is working on this with #7173

@carmocca
Copy link
Contributor

That's correct! Thanks for pinging

@carmocca carmocca assigned carmocca and unassigned awaelchli Apr 29, 2021
@awaelchli
Copy link
Contributor Author

Ok, but no duplicate right?
Is the refactor required or can we bring this fix in for 1.3? I have not yet looked closely what the issue is.

@carmocca
Copy link
Contributor

Ok, but no duplicate right?

This was reported in Slack and lazy me didn't create an issue and jumped straight into fixing it 😝

Is the refactor required or can we bring this fix in for 1.3?

The refactor is required and I would like that it makes it to 1.3, this way we don't have to worry about conflicts for the 1.4 bugfix releases.

@GuillaumeTong
Copy link

Hi, is there a temporary workaround for this issue in 1.3.0rc1? Such as maybe defining a dummy 'has_teardown_None' attribute for our datamodule? We have come to rely on some of the new features in 1.3 and cannot easily downgrade but would like to avoid waiting as much as possible.
Thank you

@carmocca
Copy link
Contributor

carmocca commented May 3, 2021

@GuillaumeTong we plan to include #7173 into 1.3 which should fix it.

Such as maybe defining a dummy 'has_teardown_None' attribute for our datamodule?

Yes, this workaround would work.

self.has_teardown_None = False

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants