# Error 'expected scalar type Half but found Float'

**URL:** <https://discuss.huggingface.co/t/error-expected-scalar-type-half-but-found-float/25685>\
**Category:** 🧨 Diffusers\
**Created:** [November 7, 2022, 3:04pm UTC](https://discuss.huggingface.co/t/error-expected-scalar-type-half-but-found-float/25685 "2022-11-07T15:04:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangjoni](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/hangjoni/32/12377_2.png) [@hangjoni](https://discuss.huggingface.co/u/hangjoni)\
**Post date:** [November 7, 2022, 3:04pm UTC](https://discuss.huggingface.co/t/error-expected-scalar-type-half-but-found-float/25685/1 "2022-11-07T15:04:09Z")

</div>

I’m following along this notebook [**sd\_dreambooth\_inference**](https://github.com/huggingface/notebooks/blob/main/diffusers/sd_dreambooth_inference.ipynb) created by HuggingFace.

I got an error ‘expected scalar type Half but found Float’ when trying to do inference

```auto
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
p = pipe(prompt, num_images_per_prompt=num_samples, num_inference_steps=50, guidance_scale=7.5)

```

I tried adding revision=“fp16” in the pipe declaration but that doesn’t help either, seeing the same error  
`pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16", torch_dtype=torch.float16).to("cuda")`

My initial guess was this has to do with the version of Pytorch. Because I can run this with no error on Google Colab, but face this error when running on Paperspace.

For reference, here are the specifications on each:

> On Paperspace with diffusers 0.4.1 and pytorch versions:
> 
> torch==1.12.0+cu116
> 
> torchaudio==0.12.0+cu116
> 
> torchvision==0.13.0+cu116
> 
> ## Works fine on Google Colab using the same diffusers version and slightly more updated version torchvision
> 
> torch @ (link)/whl/cu113/torch-1.12.1%2Bcu113-cp37-cp37m-linux\_x86\_64.whl
> 
> torchaudio @ (link)/whl/cu113/torchaudio-0.12.1%2Bcu113-cp37-cp37m-linux\_x86\_64.whl
> 
> torchsummary==1.5.1
> 
> torchtext==0.13.1
> 
> torchvision @ [https://download.pytorch.org/whl/cu113/torchvision-0.13.1%2Bcu113-cp37-cp37m-linux\_x86\_64.whl](https://download.pytorch.org/whl/cu113/torchvision-0.13.1%2Bcu113-cp37-cp37m-linux_x86_64.whl)

I have then tried to upgrade pytorch but that doesn’t work (same error)  
My current version of pytorch after upgrading:  
torch==1.13.0  
torchaudio==0.12.0+cu116  
torchvision==0.14.0

What should I do now? Is this due to the specific GPU type used, or cuda some how? How do I fix this

Thanks in advance for any help and suggestion!

---

<div class="post-metadata">

**Author:** ![pcuenq](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/pcuenq/32/32135_2.png) [@pcuenq](https://discuss.huggingface.co/u/pcuenq)\
**Post date:** [November 7, 2022, 4:27pm UTC](https://discuss.huggingface.co/t/error-expected-scalar-type-half-but-found-float/25685/2 "2022-11-07T16:27:07Z")

</div>

Perhaps you need to upgrade the `transformers` version in Paperspace?

---

<div class="post-metadata">

**Author:** ![hangjoni](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/hangjoni/32/12377_2.png) [@hangjoni](https://discuss.huggingface.co/u/hangjoni)\
**Post date:** [November 8, 2022, 12:04am UTC](https://discuss.huggingface.co/t/error-expected-scalar-type-half-but-found-float/25685/3 "2022-11-08T00:04:10Z")

</div>

Thank you so much, that works!!

It didn’t occur to me that the pipeline called transformers

For reference , the version of transformers was 4.20.1 before, and is 4.24.0 after upgrading, works now with the new transformers package version
