RuntimeError: "LayerNormKernelImpl" not implemented for 'Half' when trying inpaining
Fqlox opened this issue · comments
I wanted to use the boilerplate of the inpainting module
I downloaded the checkpoint for inpainting
from diffusers import StableDiffusionInpaintPipeline
import torch
from PIL import Image
pipe = StableDiffusionInpaintPipeline.from_pretrained(
"runwayml/stable-diffusion-inpainting",
revision="fp16",
torch_dtype=torch.float16,
)
prompt = "Face of a yellow cat, high resolution, sitting on a park bench"
#image and mask_image should be PIL images.
#The mask structure is white for inpainting and black for keeping as is
image_input = Image.open("img1.png")
image_mask = Image.open("mask.png")
image = pipe(prompt=prompt, image=image_input, mask_image=image_mask).images[0]
image.save("./yellow_cat_on_park_bench.png")
And got :
Fetching 15 files: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
██████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 15/15 [00:00<00:00, 3746.92it/s]
Traceback (most recent call last):
File "inpainting_example.py", line 17, in <module>
image = pipe(prompt=prompt, image=image_input, mask_image=image_mask).images[0]
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion_inpaint.py", line 649, in __call__
text_embeddings = self._encode_prompt(
File "G:\Anaconda3\envs\ldm\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion_inpaint.py", line 384, in _encode_prompt
text_embeddings = self.text_encoder(
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\transformers\models\clip\modeling_clip.py", line 722, in forward
return self.text_model(
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\transformers\models\clip\modeling_clip.py", line 643, in forward
encoder_outputs = self.encoder(
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\transformers\models\clip\modeling_clip.py", line 574, in forward
layer_outputs = encoder_layer(
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\transformers\models\clip\modeling_clip.py", line 316, in forward
hidden_states = self.layer_norm1(hidden_states)
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\module.py", line 1110, in _call_impl
return forward_call(*input, **kwargs)
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\modules\normalization.py", line 189, in forward
return F.layer_norm(
File "G:\Anaconda3\envs\ldm\lib\site-packages\torch\nn\functional.py", line 2486, in layer_norm
return torch.layer_norm(input, normalized_shape, weight, bias, eps, torch.backends.cudnn.enabled)
RuntimeError: "LayerNormKernelImpl" not implemented for 'Half'
I'm running this script with conda on windows 10 with an RTX2070 Super
I am also experiencing this same issue
I am also experiencing this same issue
try commenting out lines
revision="fp16", torch_dtype=torch.float16,
Chat-GPT response to the error: This error message is indicating that the LayerNormKernelImpl is not implemented for the data type "Half", which is a 16-bit floating point data type. To resolve this error, you should try converting the data type to another format that is supported, such as 32-bit floating point. Alternatively, you can try updating the library to a version that includes support for the "Half" data type.
Please not that you can only convert to torch.float16
if you're running your model on GPU - otherwise you have to run with float32. So in this case @anime26398 is right, you need to comment out:
revision="fp16", torch_dtype=torch.float16
Edit your launch.py file, find commandline_args = os.environ.get('COMMANDLINE_ARGS', "") and change it to commandline_args = os.environ.get('COMMANDLINE_ARGS', "--skip-torch-cuda-test --no-half --use-cpu all")
add this line after initialising pipe
pipe = pipe.to("cuda")
I resolved this
try commenting out lines
revision="fp16", torch_dtype=torch.float16,
Chat-GPT response to the error: This error message is indicating that the LayerNormKernelImpl is not implemented for the data type "Half", which is a 16-bit floating point data type. To resolve this error, you should try converting the data type to another format that is supported, such as 32-bit floating point. Alternatively, you can try updating the library to a version that includes support for the "Half" data type.
Thanks for answering, I just start to use python, could you please help me to find out the folder and the file to comment these sentences?
Thank you so much!