Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Update pytorch lightning utilities#15310

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@Dalton-Murray
Copy link
Contributor

@Dalton-MurrayDalton-Murray commentedMar 18, 2024
edited
Loading

Description

Changespytorch_lightning.utilities.distributed topytorch_lightning.utilities.rank_zero as this is the new/proper place to getrank_zero_only and does not exist indistributed anymore. This also (mostly) fixes the issue of it not being able to startup on clean install for those who have this error.

This change has existed for quite a few versions of pytorch lightning, and definitely exists in the current version (1.9.4).Docs

This fixes many issues such as:#13785 ,#13464 ,#11642 ,#11501 ,#11458 , and a few others
Unfortunately, this doesn't fix every issue as this does still need to change in the repositoryStability-AI/stablediffusion

Checklist:

@AUTOMATIC1111
Copy link
Owner

What about an option where you assign topytorch_lightning.utilities.distributed, something likepytorch_lightning.utilities.distributed = pytorch_lightning.utilities.rank_zero, to make the code work without changes?

@Dalton-Murray
Copy link
ContributorAuthor

Dalton-Murray commentedMar 18, 2024
edited
Loading

I want to confirm what you mean by this, I guess I'm a little confused. This snippet is from ddpm, do you mean something like this:

fromtorchvision.utilsimportmake_gridpytorch_lightning.utilities.distributed=pytorch_lightning.utilities.rank_zerofrompytorch_lightning.utilities.rank_zeroimportrank_zero_onlyfromomegaconfimportListConfig

If so, this doesn't work becausepytorch_lightning is not defined.

Another way I tried was this, but this doesn't seem to work:

importpytorch_lightning.utilities.rank_zeroasrank_zeroimportpytorch_lightning.utilities.distributedasdistributeddistributed=rank_zerodistributed.rank_zero_only()

However, this still does require some initial modification of thefrom pytorch_lightning.utilities.distributed import rank_zero_only line.
This, also doesn't seem to work as it still does try to initially import fromdistributed and results an error for me:

ModuleNotFoundError: No module named 'pytorch_lightning.utilities.distributed'Press any key to continue . . .

Perhaps, I am thinking about this or doing this incorrectly.

This is another way I thought of but doesn't work:

importpytorch_lightning.utilities.rank_zeroasrank_zerodefdistributed():returnrank_zerofrompytorch_lightning.utilities.distributedimportrank_zero_only

Something like this would work, but it does change the code (and is technically unnecessary since it doesn't do anything withdistributed:

importpytorch_lightning.utilities.rank_zeroasdistributedfrompytorch_lightning.utilities.rank_zeroimportrank_zero_only

If you prefer, I could instead replace this with a try catch/except like this which does work:

try:frompytorch_lightning.utilities.distributedimportrank_zero_onlyexcept:frompytorch_lightning.utilities.rank_zeroimportrank_zero_only

Sorry for the wall, this was just me trying to figure out a way of doing this

@AUTOMATIC1111
Copy link
Owner

Something like this:

import pytorch_lightning.utilities.rank_zerosys.modules["pytorch_lightning.utilities.xxx"] = pytorch_lightning.utilities.rank_zerofrom pytorch_lightning.utilities.xxx import rank_zero_onlyrank_zero_only> <function lightning_utilities.core.rank_zero.rank_zero_only(fn: Callable) -> Callable>

@Dalton-Murray
Copy link
ContributorAuthor

That'd totally work! I just skipped over it initially because I wasn't sure if you wanted to allow importing sys or not because it's not already being imported, will adapt it to current edits

@AUTOMATIC1111
Copy link
Owner

What I'm suggesting is to do this once, somewhere in code that's executed early (ie a function ininitialize_util called frominitialize.initialize()), and then all codebases will be able to usefrom pytorch_lightning.utilities.distributed import rank_zero_only.

You just gotta be careful and not replacepytorch_lightning.utilities.distributed if it exists already (which I assume is the case in the c uirrently used version of pytorch_lightning).

@Dalton-Murray
Copy link
ContributorAuthor

That'd make more sense! I'll revert and work on implementing something like that

@Dalton-Murray
Copy link
ContributorAuthor

Dalton-Murray commentedMar 21, 2024
edited
Loading

Not sure if you want to keep the print statement in there or not as it's a bit unnecessary I feel like?

@Dalton-Murray
Copy link
ContributorAuthor

Sorry, I forgot to revert a few lines back, should be good now

@Dalton-Murray
Copy link
ContributorAuthor

Sorry, a bit of a mess, the import was actually definitely required but I moved it further down into the if

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@AUTOMATIC1111AUTOMATIC1111AUTOMATIC1111 approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@Dalton-Murray@AUTOMATIC1111

[8]ページ先頭

©2009-2025 Movatter.jp