英文:
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're logged in with `huggingface-cli login`
from diffusers import StableDiffusionPipeline
pipe = StableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5")
pipe = pipe.to("mps")
# Recommended if your computer has < 64 GB of RAM
pipe.enable_attention_slicing()
prompt = "a photo of an astronaut riding a horse on mars"
# First-time "warmup" 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 "/Users/apple/Desktop/area_51/stable-diffusion.py", line 2, in <module>
from diffusers import StableDiffusionPipeline
ModuleNotFoundError: No module named 'diffusers'
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论