Error: Input type (c10::Half) and bias type (float) should be the same

#91
by gbhatt2 - opened

Hi,
I am trying to run a simple batched image generation using :

with torch.no_grad():
p = "An astronaut riding a green horse"
prompt = [p for _ in range(7)]
images = pipe(prompt=prompt).images[0]

It throws the following error.

'''

RuntimeError Traceback (most recent call last)
Cell In[7], line 5
3 p = "An astronaut riding a green horse"
4 prompt = [p for _ in range(7)]
----> 5 images = pipe(prompt=prompt).images[0]

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/torch/autograd/grad_mode.py:27, in _DecoratorContextManager.call..decorate_context(*args, **kwargs)
24 @functools.wraps(func)
25 def decorate_context(*args, **kwargs):
26 with self.clone():
---> 27 return func(*args, **kwargs)

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py:867, in StableDiffusionXLPipeline.call(self, prompt, prompt_2, height, width, num_inference_steps, denoising_end, guidance_scale, negative_prompt, negative_prompt_2, num_images_per_prompt, eta, generator, latents, prompt_embeds, negative_prompt_embeds, pooled_prompt_embeds, negative_pooled_prompt_embeds, output_type, return_dict, callback, callback_steps, cross_attention_kwargs, guidance_rescale, original_size, crops_coords_top_left, target_size, negative_original_size, negative_crops_coords_top_left, negative_target_size)
864 self.upcast_vae()
865 latents = latents.to(next(iter(self.vae.post_quant_conv.parameters())).dtype)
--> 867 image = self.vae.decode(latents / self.vae.config.scaling_factor, return_dict=False)[0]
869 # cast back to fp16 if needed
870 if needs_upcasting:

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/diffusers/utils/accelerate_utils.py:46, in apply_forward_hook..wrapper(self, *args, **kwargs)
44 if hasattr(self, "_hf_hook") and hasattr(self._hf_hook, "pre_forward"):
45 self._hf_hook.pre_forward(self)
---> 46 return method(self, *args, **kwargs)

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/diffusers/models/autoencoder_kl.py:286, in AutoencoderKL.decode(self, z, return_dict)
284 decoded = torch.cat(decoded_slices)
285 else:
--> 286 decoded = self._decode(z).sample
288 if not return_dict:
289 return (decoded,)

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/diffusers/models/autoencoder_kl.py:272, in AutoencoderKL._decode(self, z, return_dict)
269 if self.use_tiling and (z.shape[-1] > self.tile_latent_min_size or z.shape[-2] > self.tile_latent_min_size):
270 return self.tiled_decode(z, return_dict=return_dict)
--> 272 z = self.post_quant_conv(z)
273 dec = self.decoder(z)
275 if not return_dict:

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/torch/nn/modules/module.py:1190, in Module._call_impl(self, *input, **kwargs)
1186 # If we don't have any hooks, we want to skip the rest of the logic in
1187 # this function, and just call forward.
1188 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1189 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1190 return forward_call(*input, **kwargs)
1191 # Do not call functions when jit is used
1192 full_backward_hooks, non_full_backward_hooks = [], []

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/torch/nn/modules/conv.py:463, in Conv2d.forward(self, input)
462 def forward(self, input: Tensor) -> Tensor:
--> 463 return self._conv_forward(input, self.weight, self.bias)

File ~/.conda/envs/pyv2/lib/python3.10/site-packages/torch/nn/modules/conv.py:459, in Conv2d._conv_forward(self, input, weight, bias)
455 if self.padding_mode != 'zeros':
456 return F.conv2d(F.pad(input, self._reversed_padding_repeated_twice, mode=self.padding_mode),
457 weight, bias, self.stride,
458 _pair(0), self.dilation, self.groups)
--> 459 return F.conv2d(input, weight, bias, self.stride,
460 self.padding, self.dilation, self.groups)

RuntimeError: Input type (c10::Half) and bias type (float) should be the same

'''

Same trouble.

same trouble

Sign up or log in to comment