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

Recursion error when following DataParallel tutorial #836

Closed
florisdf opened this issue Jan 27, 2020 · 1 comment · Fixed by #2389
Closed

Recursion error when following DataParallel tutorial #836

florisdf opened this issue Jan 27, 2020 · 1 comment · Fixed by #2389
Assignees
Labels
docathon-h1-2023 A label for the docathon in H1 2023 medium

Comments

@florisdf
Copy link

florisdf commented Jan 27, 2020

The parallelism tutorial mentions this code to forward the attributes of a DataParallel object to its wrapped module:

class MyDataParallel(nn.DataParallel):
    def __getattr__(self, name):
        return getattr(self.module, name)

This, however, leads to a recursion error, as self.module will call the same __getattr__ again. I think it should be:

class MyDataParallel(DataParallel):
    def __getattr__(self, name):
        try:
            return super().__getattr__(name)
        except AttributeError:
            return getattr(self.module, name)

As was discussed here.

@svekars svekars added medium docathon-h1-2023 A label for the docathon in H1 2023 labels May 31, 2023
@TheMemoryDealer
Copy link
Contributor

/assigntome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docathon-h1-2023 A label for the docathon in H1 2023 medium
Projects
None yet
3 participants