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

"Advanced" profiler not working #6522

Closed
bnaman50 opened this issue Mar 15, 2021 · 3 comments · Fixed by #6621
Closed

"Advanced" profiler not working #6522

bnaman50 opened this issue Mar 15, 2021 · 3 comments · Fixed by #6621
Assignees
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task

Comments

@bnaman50
Copy link

🐛 Bug

Hello Guys,

I am having issues with the advanced profiling option in lightning. Here is the colab file documenting the issue on a simple model.

The issue happens, whenever I set stochastic_weight_avg=True.

Also, I have my complicated setup where I faced issue regarding Advanced profiler but it was a different one. When I tried to reproduce it, I faced the above mentioned issue. Thus, I am just mentioning my actual error over here.

Here is how I call my trainer -

trainer = pl.Trainer.from_argparse_args(args,
                                            callbacks=[LoggingCallback(), checkpoint_callback],
                                            profiler="advanced",
                                            )

And here is the error stack -

Traceback (most recent call last):
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "/home/nzb0040/.pyenv/versions/intersection_train/lib/python3.8/site-packages/pytorch_lightning/profiler/profilers.py", line 71, in profile
    yield action_name
  File "/home/nzb0040/.pyenv/versions/intersection_train/lib/python3.8/site-packages/pytorch_lightning/trainer/trainer.py", line 1102, in call_hook
    trainer_hook(*args, **kwargs)
  File "/home/nzb0040/.pyenv/versions/intersection_train/lib/python3.8/site-packages/pytorch_lightning/trainer/callback_hook.py", line 35, in on_before_accelerator_backend_setup
    callback.on_before_accelerator_backend_setup(self, model)
  File "/home/nzb0040/.pyenv/versions/intersection_train/lib/python3.8/site-packages/pytorch_lightning/callbacks/swa.py", line 142, in on_before_accelerator_backend_setup
    self._average_model = deepcopy(pl_module)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 270, in _reconstruct
    state = deepcopy(state, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 146, in deepcopy
    y = copier(x, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 230, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
  File "/home/nzb0040/.pyenv/versions/3.8.6/lib/python3.8/copy.py", line 161, in deepcopy
    rv = reductor(4)
TypeError: cannot pickle 'Profile' object
Exception ignored in: <function AdvancedProfiler.__del__ at 0x7f045ad834c0>
Traceback (most recent call last):
  File "/home/nzb0040/.pyenv/versions/intersection_train/lib/python3.8/site-packages/pytorch_lightning/profiler/profilers.py", line 280, in __del__
    if self.output_file:
AttributeError: 'AdvancedProfiler' object has no attribute 'output_file'
@bnaman50 bnaman50 added bug Something isn't working help wanted Open to be worked on labels Mar 15, 2021
@edenlightning edenlightning added the priority: 0 High priority task label Mar 16, 2021
@justusschock
Copy link
Member

Hey @bnaman50 ,

Thanks for the issue. You're right, there seem to be some pickling issues with this profiler.
#6552 fixes this for me. Can you try that one? :)

@bnaman50
Copy link
Author

Hey, I am still facing the same issue even with the new version (1.2.4).

P.S. - Reference code is there in the same colab.

Thanks,
Naman

@justusschock
Copy link
Member

@bnaman50 ,

Yes the 1.2.4 release does not include that fix, since the PR is not yet merged. You could try to install from that specific git branch. Hopefully, the PR will be merged by the next release.

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
3 participants