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

FluxPipeline Error: Trying to set a tensor of shape torch.Size([3072]) in "bias" (which has shape torch.Size([576])), this looks incorrect. #190

Open
ReppiksProductions opened this issue Nov 6, 2024 · 0 comments

Comments

@ReppiksProductions
Copy link

Greetings,
I've been trying to setup a CLI script to run FLUX.1-dev to generate images to test LORAs. I am interested in it because I prefer not to have to load up a large GUI for doing simple sample images.

I was having issues with my script so I decided to try out the example on the homepage of the FluxPipeline. When I run my script as well as the FluxPipeline example I get the following error: ValueError: Trying to set a tensor of shape torch.Size([3072]) in "bias" (which has shape torch.Size([576])), this looks incorrect.

Here is my Traceback:

A matching Triton is not available, some optimizations will not be enabled
Traceback (most recent call last):
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\xformers_init_.py", line 57, in _is_triton_available
import triton # noqa
ModuleNotFoundError: No module named 'triton'
Loading pipeline components...: 29%|██████████████▊ | 2/7 [00:00<00:00, 28.57it/s]
Traceback (most recent call last):
File "E:_python_projects\gen_img_diffusers_v9\test.py", line 6, in
pipe = FluxPipeline.from_pretrained("C:_Python Projects\StableDiffusionModels\Full\FLUX.1-Dev", torch_dtype=torch.bfloat16)
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\diffusers\pipelines\pipeline_utils.py", line 896, in from_pretrained
loaded_sub_model = load_sub_model(
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\diffusers\pipelines\pipeline_loading_utils.py", line 704, in load_sub_model
loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\huggingface_hub\utils_validators.py", line 114, in _inner_fn
return fn(*args, **kwargs)
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\diffusers\models\modeling_utils.py", line 886, in from_pretrained
accelerate.load_checkpoint_and_dispatch(
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\accelerate\big_modeling.py", line 613, in load_checkpoint_and_dispatch
load_checkpoint_in_model(
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\accelerate\utils\modeling.py", line 1780, in load_checkpoint_in_model
set_module_tensor_to_device(
File "E:_python_projects\gen_img_diffusers_v9\env\lib\site-packages\accelerate\utils\modeling.py", line 286, in set_module_tensor_to_device
raise ValueError(
ValueError: Trying to set a tensor of shape torch.Size([3072]) in "bias" (which has shape torch.Size([576])), this looks incorrect.

This is my python code:

`import torch
from diffusers import FluxPipeline

model_id = "C:_Python Projects\StableDiffusionModels\Full\FLUX.1-Dev" #you can also use black-forest-labs/FLUX.1-dev

pipe = FluxPipeline.from_pretrained("C:_Python Projects\StableDiffusionModels\Full\FLUX.1-Dev", torch_dtype=torch.bfloat16)
pipe.enable_model_cpu_offload() #save some VRAM by offloading the model to CPU. Remove this if you have enough GPU power

prompt = "A cat holding a sign that says hello world"
seed = 42
image = pipe(
prompt,
output_type="pil",
num_inference_steps=4, #use a larger number if you are using [dev]
generator=torch.Generator("cpu").manual_seed(seed)
).images[0]
image.save("flux-schnell.png")`

I'm using Python 3.10.11
Pytorch 2.5.1+cu124
Diffusers 0.32.0.dev0 (I started with 0.31.0 but downloaded latest hoping it would fix my issue)

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

1 participant