无法将稳定的差分流程移至我的M1 MacBook。

huangapple go评论54阅读模式
英文:

Unable to move the Stable Diffusion pipeline to my M1 MacBook

问题

我按照这里的步骤进行操作:如何在苹果Silicon(M1/M2)上使用稳定扩散

在我的本地 MacBook M1 机器上,我将以下脚本保存在 stable-diffusion.py 文件中:

# 确保您已经使用 `huggingface-cli login` 登录
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("mps")

# 如果您的计算机内存小于 64 GB,建议启用注意力分片
pipe.enable_attention_slicing()

prompt = "一名宇航员在火星上骑马的照片"

# 第一次“热身”传递(请参阅上面的解释)
_ = pipe(prompt, num_inference_steps=1)

# 经过热身传递后,结果与 CPU 设备的结果匹配
image = pipe(prompt).images[0]

现在,当我尝试在终端中执行:python stable-diffusion.py 时,我遇到以下错误:

Traceback (most recent call last):
  File "/Users/apple/Desktop/area_51/stable-diffusion.py", line 2, in <module>
    from diffusers import StableDiffusionPipeline
ModuleNotFoundError: No module named 'diffusers'

为了修复它,我甚至尝试了:pip install diffusers,但仍然遇到相同的错误。

我是否遗漏了什么?

英文:

I am following the steps stated here: How to use Stable Diffusion in Apple Silicon (M1/M2).

At my local MacBook M1 machine, I saved the below script in stable-diffusion.py file:

# make sure you&#39;re logged in with `huggingface-cli login`
from diffusers import StableDiffusionPipeline

pipe = StableDiffusionPipeline.from_pretrained(&quot;runwayml/stable-diffusion-v1-5&quot;)
pipe = pipe.to(&quot;mps&quot;)

# Recommended if your computer has &lt; 64 GB of RAM
pipe.enable_attention_slicing()

prompt = &quot;a photo of an astronaut riding a horse on mars&quot;

# First-time &quot;warmup&quot; pass (see explanation above)
_ = pipe(prompt, num_inference_steps=1)

# Results match those from the CPU device after the warmup pass.
image = pipe(prompt).images[0]

Now when I am trying to execute: python stable-diffusion.py from Terminal, I am getting following error:

Traceback (most recent call last):
  File &quot;/Users/apple/Desktop/area_51/stable-diffusion.py&quot;, line 2, in &lt;module&gt;
    from diffusers import StableDiffusionPipeline
ModuleNotFoundError: No module named &#39;diffusers&#39;

In order to fix it even I tried: pip install diffusers, however I still got same error.

Am I missing anything over here?

答案1

得分: 1

尝试从源代码安装:

pip3 install -U git+https://github.com/huggingface/diffusers.git

对我有效。

英文:

Try installing from source:

pip3 install -U git+https://github.com/huggingface/diffusers.git

Worked for me.

huangapple
  • 本文由 发表于 2023年2月16日 02:51:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/75464250.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定