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

Error: No name 'rank_zero_only' in module 'pytorch_lightning.utilities.distributed' #4

Open
halr9000 opened this issue Jan 7, 2024 · 6 comments

Comments

@halr9000
Copy link

halr9000 commented Jan 7, 2024

Looks like rank_zero_only was moved in the version of pytorch I'm running. I was able to patch my copy to the new location and it's working fine for me. phind.com details below:


I'm getting this message during compilation:

Pylint(E0611:no-name-in-module https://pylint.readthedocs.io/en/latest/user_guide/messages/error/no-name-in-module.html) Error: No name 'rank_zero_only' in module 'pytorch_lightning.utilities.distributed'

Related to this line in d:\hal\stable-diffusion\StabilityMatrix\Packages\ComfyUI\custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\ldm\models\diffusion\ddpm.py:

19: from pytorch_lightning.utilities.distributed import rank_zero_only

The error message you're encountering indicates that the rank_zero_only function cannot be found within the pytorch_lightning.utilities.distributed module. This could be due to changes in the PyTorch Lightning library where the function was moved or renamed.

To resolve this issue, you should check the current version of PyTorch Lightning that you're using and look for the updated location or name of the rank_zero_only function. Since the documentation link provided is not working and there's no direct information about the change, you can try importing rank_zero_only from pytorch_lightning.utilities instead, as shown below:

from pytorch_lightning.utilities import rank_zero_only

If this does not work, you may need to consult the latest PyTorch Lightning documentation or source code to find the new location of the rank_zero_only function. It's also possible that you might need to update your PyTorch Lightning version if the function has been moved in a newer release.

@NertonSaintfort
Copy link

Thank you for this that fix it

@DenRakEiw
Copy link

I have the same error, how can I fix it ?

@DenRakEiw
Copy link

Error occurred when executing LDSRUpscaler:

cannot import name '_is_local_file_protocol' from 'lightning_fabric.utilities.cloud_io' (F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\lightning_fabric\utilities\cloud_io.py)

File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 154, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 84, in get_output_data
return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 77, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Flowty-LDSR_init_.py", line 123, in upscale
outputs.append(ldsr.superResolution(image, int(steps), pre_downscale, post_downscale, downsample_method))
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\LDSR.py", line 261, in superResolution
model = self.load_model_from_config()
File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\LDSR.py", line 88, in load_model_from_config
self.model = LDSR.load_model_from_path(self.modelPath, self.torchdevice)
File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\LDSR.py", line 75, in load_model_from_path
pl_sd = torch.load(modelPath, map_location="cpu")
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\serialization.py", line 1014, in load
return load(opened_zipfile,
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\serialization.py", line 1422, in load
result = unpickler.load()
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\torch\serialization.py", line 1415, in find_class
return super().find_class(mod_name, name)
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\pytorch_lightning_init
.py", line 27, in
from pytorch_lightning.callbacks import Callback # noqa: E402
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\pytorch_lightning\callbacks_init
.py", line 24, in
from pytorch_lightning.callbacks.model_checkpoint import ModelCheckpoint
File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\pytorch_lightning\callbacks\model_checkpoint.py", line 37, in
from lightning_fabric.utilities.cloud_io import _is_dir, _is_local_file_protocol, get_filesystem

@flowtyone flowtyone mentioned this issue Jan 13, 2024
@hiorws
Copy link

hiorws commented Feb 2, 2024

You can change the line 19 in the file custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\ldm\models\diffusion\ddpm.py
from pytorch_lightning.utilities.distributed import rank_zero_only
with
from pytorch_lightning.utilities.rank_zero import rank_zero_only

I hope it works for you.

@yarik1988
Copy link

You can change the line 19 in the file custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\ldm\models\diffusion\ddpm.py from pytorch_lightning.utilities.distributed import rank_zero_only with from pytorch_lightning.utilities.rank_zero import rank_zero_only

I hope it works for you.

this should definitely be updated in repo

@microvswind
Copy link

You can change the line 19 in the file custom_nodes\ComfyUI-Flowty-LDSR\ldsrlib\ldm\models\diffusion\ddpm.py from pytorch_lightning.utilities.distributed import rank_zero_only with from pytorch_lightning.utilities.rank_zero import rank_zero_only
I hope it works for you.

this should definitely be updated in repo

work, thx so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants