torch.float16 give me this error

#2
by Valerioweb - opened

File "/root/.pyenv/versions/3.11.1/lib/python3.11/site-packages/torch/nn/modules/linear.py", line 114, in forward
return F.linear(input, self.weight, self.bias)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: mat1 and mat2 must have the same dtype, but got Float and Half

This is working fine on Colab,

from diffusers import DiffusionPipeline, LCMScheduler
import torch
import mediapy

model_id = "stabilityai/stable-diffusion-xl-base-1.0"
lcm_lora_id = "latent-consistency/lcm-lora-sdxl"

pipe = DiffusionPipeline.from_pretrained(model_id, variant="fp16", torch_dtype=torch.float16)

pipe.load_lora_weights(lcm_lora_id, torch_dtype=torch.float16)
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.to(device="cuda", dtype=torch.float16)

prompt = "close-up photography of old man standing in the rain at night, in a street lit by lamps, leica 35mm summilux"
images = pipe(
    prompt=prompt,
    num_inference_steps=4,
    guidance_scale=1,
).images[0]

mediapy.show_image(images)
Latent Consistency org

Thanks @Vargol , @Valerioweb are you still getting that error?

I wasn't getting the error, I'd guess from the original error that @Valerioweb had part of the model on the CPU and part on the GPU.

Sign up or log in to comment