question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'Parameter' object has no attribute 'named_children'

See original GitHub issue

Describe the bug

Hi, friends, I meet a problem I hope to get your help.

When I run the code as follow:

`from diffusers import StableDiffusionPipeline import torch

pipe = StableDiffusionPipeline.from_pretrained(“PATH_OF_MODEL/stable-diffusion”,device_map=“auto”,torch_type=torch.float16, revision=“fp16”) ` I save the model in the path “PATH_OF_MODEL/stable-diffusion” from the https://huggingface.co/CompVis/stable-diffusion-v1-4/tree/main Then, I get the error as follow:

ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy. Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/diffusers/pipeline_utils.py", line 517, in from_pretrained loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs) File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2265, in from_pretrained device_map = infer_auto_device_map( File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/accelerate/utils/modeling.py", line 480, in infer_auto_device_map max_layer_size, max_layer_names = get_max_layer_size(modules_to_treat, module_sizes, no_split_module_classes) File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/accelerate/utils/modeling.py", line 261, in get_max_layer_size modules_children = list(module.named_children()) AttributeError: 'Parameter' object has no attribute 'named_children' My environment: python=3.9.13, diffusers=0.5.1 torch=1.12.1, transformers = 4.12.1, spacy = 3.4.1,accelerate=0.13.1 which run on ubuntu=22.04.

I don’t know why, I sincerely to get your team help.Thanks,bro!

Reproduction

`from diffusers import StableDiffusionPipeline import torch

pipe = StableDiffusionPipeline.from_pretrained(“PATH_OF_MODEL/stable-diffusion”,device_map=“auto”,torch_type=torch.float16, revision=“fp16”)’

Logs

`ftfy or spacy is not installed using BERT BasicTokenizer instead of ftfy.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/diffusers/pipeline_utils.py", line 517, in from_pretrained
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/transformers/modeling_utils.py", line 2265, in from_pretrained
    device_map = infer_auto_device_map(
  File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/accelerate/utils/modeling.py", line 480, in infer_auto_device_map
    max_layer_size, max_layer_names = get_max_layer_size(modules_to_treat, module_sizes, no_split_module_classes)
  File "/home/klyuhang9/miniconda3/envs/PY_TEST/lib/python3.9/site-packages/accelerate/utils/modeling.py", line 261, in get_max_layer_size
    modules_children = list(module.named_children())
AttributeError: 'Parameter' object has no attribute 'named_children'

System Info

My environment: python=3.9.13, diffusers=0.5.1 torch=1.12.1, transformers = 4.12.1, spacy = 3.4.1,accelerate=0.13.1 which run on ubuntu=22.04.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sguggercommented, Oct 17, 2022

Patch is out on Pypi.

0reactions
github-actions[bot]commented, Dec 4, 2022

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Parameter' object has no attribute 'grad_sample' · Issue #4 ...
AttributeError : 'Parameter' object has no attribute 'grad_sample'. My model uses LSTM+attention and linear layers. But I can run your mnist ...
Read more >
AttributeError: 'TFBertModel' object has no attribute 'parameters'
Hello I am trying to train a Bert Model for a tokenizer I had trained. I imported from transformers import TFBertModel model ...
Read more >
'module' object has no attribute 'Parameter' from Python ...
pyt file everything works perfectly, but when file is splited i get this message: AttributeError: 'module' object has no attribute 'Parameter'.
Read more >
AttributeError: 'Model' object has no attribute 'parameters'
I am using a modified Resnet18, with my own pooling function at the end of the Resnet. Here is my code: resnet =...
Read more >
inspect — Inspect live objects — Python 3.11.1 documentation
If the parameter has no annotation, this attribute is set to Parameter.empty . kind¶. Describes how argument values are bound to the parameter....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found