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

FluxInpaintPipeline error when im using DataParallel to use multiple gpus #10640

Open
Himasnhu-AT opened this issue Jan 24, 2025 · 3 comments
Open
Labels
bug Something isn't working

Comments

@Himasnhu-AT
Copy link

Describe the bug

line 175, in forward
for t in chain(self.module.parameters(), self.module.buffers()):
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/tensorflow/lib/python3.12/site-packages/diffusers/configuration_utils.py", line 143, in getattr
raise AttributeError(f"'{type(self).name}' object has no attribute '{name}'")
AttributeError: 'FluxFillPipeline' object has no attribute 'parameters'

Reproduction

if torch.cuda.device_count() > 1:
pipe = torch.nn.DataParallel(pipe)
pipe = pipe.to("cuda")

Logs

System Info

Ubuntu AWS deep learning AMI

g5.12xlarge
4A10 GPUS

Who can help?

No response

@Himasnhu-AT Himasnhu-AT added the bug Something isn't working label Jan 24, 2025
@a-r-r-o-w
Copy link
Member

DP needs to be applied on torch modules. The pipelines are not torch modules, so it is expected to not work. Instead, you can initialise the modules separately, wrap with DP, then create a per-device pipeline by initialising with the modules.

@Himasnhu-AT
Copy link
Author

okay, is there a way to make it part of the pipeline itself as it'll be easier for other to use it too

@Himasnhu-AT
Copy link
Author

Himasnhu-AT commented Feb 3, 2025

here's im doing it:

pipe = FluxFillPipeline.from_pretrained("black-forest-labs/FLUX.1-Fill-dev", torch_dtype=torch.bfloat16, 
device_map="balanced", max_memory={0:"23GB", 1: "23GB", 2: "23GB", 3: "23GB"})


    image = pipe(
        # mask_image_latent=vae.encode(controlImage),
        prompt=prompt,
        prompt_2=prompt,
        image=image,
        mask_image=mask,
        height=height,
        width=width,
        guidance_scale=guidance_scale,
        # strength=strength,
        num_inference_steps=num_inference_steps,
        # generator=torch.Generator(device='cuda').manual_seed(seed),
        # generator=torch.Generator().manual_seed(seed),
        # lora_scale=0.75 // not supported in this version
    ).images[0]

Error:

Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! 
(when checking argument for argument mat2 in method wrapper_CUDA_mm)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants