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

KFold cross validation example: Trainer has no attribute 'strategy' #11565

Closed
KevinCrp opened this issue Jan 21, 2022 · 2 comments
Closed

KFold cross validation example: Trainer has no attribute 'strategy' #11565

KevinCrp opened this issue Jan 21, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@KevinCrp
Copy link

🐛 Bug

I'm trying the K-Fold cross-validation example from pl_examples.
When I run the example, there is an error
AttributeError: 'Trainer' object has no attribute 'strategy'

`Traceback (most recent call last):

File "test_kflod.py", line 281, in
trainer.fit(model, datamodule)

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 740, in fit
self._call_and_handle_interrupt(

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 685, in _call_and_handle_interrupt
return trainer_fn(*args, **kwargs)

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 777, in _fit_impl
self._run(model, ckpt_path=ckpt_path)

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1199, in _run
self._dispatch()

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1279, in _dispatch
self.training_type_plugin.start_training(self)

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/plugins/training_type/training_type_plugin.py", line 202, in start_training
self._results = trainer.run_stage()

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1289, in run_stage
return self._run_train()

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1319, in _run_train
self.fit_loop.run()

File "/home/[USER]/[PATH]/lib/python3.8/site-packages/pytorch_lightning/loops/base.py", line 146, in run
self.on_advance_end()

File "test_kflod.py", line 206, in on_advance_end
self.trainer.strategy.setup_optimizers(self.trainer)

AttributeError: 'Trainer' object has no attribute 'strategy'`

Expected behavior

Environment

  • PyTorch Lightning Version (e.g., 1.5.0): 1.5.8 (Conda)
  • PyTorch Version (e.g., 1.10): 1.10.0 (pip)
  • Python version (e.g., 3.9): 3.8.12
  • OS (e.g., Linux): WSL
  • CUDA/cuDNN version: -
  • GPU models and configuration: -
  • How you installed PyTorch (conda, pip, source): pip
  • If compiling from source, the output of torch.__config__.show():
  • Any other relevant information:

Additional context

@KevinCrp KevinCrp added the bug Something isn't working label Jan 21, 2022
@rohitgr7
Copy link
Contributor

hey @KevinCrp !
the example there will work fine on master since Loops are currently experimental.
Check out the conversation here for more info and workaround: #11230 (comment)

@KevinCrp
Copy link
Author

It works, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants