我运行稳定扩散,这是错误的 RuntimeError: "LayerNormKernelImpl" not Implemented for 'Half',

吾发克*_*吾发克 21 stable-diffusion

我运行稳定扩散,这是错误的 RuntimeError:“LayerNormKernelImpl”未实现“Half”,请帮助我,我该怎么办?

我不知道

Man*_*han 21

“LayerNorm”是模型中的层之一。看起来您正在尝试在不支持的 CPU 上加载 float16(Half) 格式的扩散模型。对于float16格式,需要使用GPU。对于 CPU,以 float32 格式运行模型。

参考: https: //github.com/pytorch/pytorch/issues/52291

  • `dtype=torch.float16 ——> dtype=torch.float32` 谢谢您的链接 (6认同)

小智 17

我按照下面的方式解决了,launch.py按照下面的方式修改文件,添加下面一行代码:

commandline_args = os.environ.get('COMMANDLINE_ARGS', "--skip-torch-cuda-test --no-half")
Run Code Online (Sandbox Code Playgroud)

launch.py​​ 文件和修改后的代码行如上所述


小智 8

我不确定你的环境是什么。我可以告诉你我遇到过什么。我在 Colab 测试期间也遇到了这个错误,该错误是在我更改模型后出现的。然后我意识到我忘记将管道分配给 CUDA。运行下面的代码后,一切都很好。

pipe = pipe.to("cuda")
Run Code Online (Sandbox Code Playgroud)


小智 8

使用 实例化管道float32,它会运行得更慢,但它会运行;)

pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
Run Code Online (Sandbox Code Playgroud)