在安装stable diffusioin的时候出现这个错误:
各位能帮我看看是什么问题么?谢谢。
(sdwebui) D:\stable-diffusion-webui>webui-user.bat
venv "D:\stable-diffusion-webui\venv\Scripts\Python.exe"
Python 3.10.6 | packaged by conda-forge | (main, Oct 24 2022, 16:02:16) [MSC v.1916 64 bit (AMD64)]
Commit hash: 22bcc7be428c94e9408f589966c2040187245d81
Traceback (most recent call last):
File "D:\stable-diffusion-webui\launch.py", line 355, in
prepare_environment()
File "D:\stable-diffusion-webui\launch.py", line 288, in prepare_environment
git_clone(stable_diffusion_repo, repo_dir('stable-diffusion-stability-ai'), "Stable Diffusion", stable_diffusion_commit_hash)
File "D:\stable-diffusion-webui\launch.py", line 143, in git_clone
current_hash = run(f'"{git}" -C "{dir}" rev-parse HEAD', None, f"Couldn't determine {name}'s hash: {commithash}").strip()
File "D:\stable-diffusion-webui\launch.py", line 97, in run
raise RuntimeError(message)
RuntimeError: Couldn't determine Stable Diffusion's hash: cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf.
Command: "git" -C "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai" rev-parse HEAD
Error code: 128
stdout: HEAD
stderr: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git [...] -- [...]'
不知道你这个问题是否已经解决, 如果还没有解决的话:第一个问题官网是有说明的,但就是这个下载地址藏得很深不好找。
我也是找了一会才找到
下载模型文件放置到这个文件夹下,就是上面官方说明的那个位置,命名成model.ckpt。
运行下面的代码,不出意外会报错。
python scripts/txt2img.py --prompt "a photograph of an astronaut riding a horse" --plms
问题好像是原作者修改了这个库,将你的quantize.py(报错的信息里包含文件所在的绝对路径)文件替换成这个网址的文件
https://github.com/CompVis/taming-transformers/blob/master/taming/modules/vqvae/quantize.py
再运行一次又报错
我只是12g的3060,看来这不是一般人能玩得起的-_-
!!!!!!!!!!!!!!!!
现在有一个简单的办法了,感谢数学系之耻的建议,直接降精度就可以释放显存了。
!!!!!!!!!!!!!!!!
如下修改txt2img.py文件第244行
效果 -->
或者接下去看比较复杂的方法!
不知道需要多大的内存才可以,网上找到方法是用优化的库。网上还有一种办法说注释掉什么安全检查的我试了没有变化。
https://github.com/basujindal/stable-diffusion
下载完后在新的库上也是需要安装一些环境,在新的文件夹下运行下面的安装代码
pip install -e .
优化的库代码放在optimizedSD文件夹下,也保留了之前的源代码,不要搞错了。
重新安装一下这个优化库的环境,将ckpt放到对应的位置。
python optimizedSD/optimized_txt2img.py --prompt "Cyberpunk style image of a Tesla car reflection in rain" --H 512 --W 512 --seed 27 --n_iter 2 --n_samples 5 --ddim_steps 50
运行后报这个错。
查了一下,好像是最近优化的作者也换了一个库
https://github.com/basujindal/stable-diffusion/issues/175
用下面的办法就能解决了。
pip install git+https://github.com/crowsonkb/k-diffusion.git
然后打开编辑optimizedSD/ddpm.py文件,将from samplers…改成上面图片的三个from k_diffusion…
然后贫穷的显卡的电脑也就可以跑了,不说了要努力搬砖买24g的显卡了。
实测效果 -->