flowtyone / ComfyUI-Flowty-LDSR

LDSR custom node for ComfyUI
GNU General Public License v3.0
199 stars 14 forks source link

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

Open halr9000 opened 10 months ago

halr9000 commented 10 months ago

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 commented 9 months ago

Thank you for this that fix it

DenRakEiw commented 9 months ago

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

DenRakEiw commented 9 months ago

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

hiorws commented 9 months ago

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 commented 9 months ago

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 commented 8 months ago

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