版权归作者所有,任何形式转载请联系作者。

作者:邻家的の柠檬叔(来自豆瓣)

来源:https://www.douban.com/note/845051967/


参考的是:www.bilibili.com/read/cv20466834


我机器已经有了anacoda,所以很多预制条件已经满足。


1、git有了


2、pyhton本身有了,当然需要切一下版本到3.10


首先需要升级一下conda本身


conda update -n base -c defaults conda

但是发现这个命令在11下权限不足,那行吧,还得用runas感觉


runas /noprofile /user:LEMON-HP-LAPTOP\administrator cmd

然而很不幸,runas命令是需要配置用户名和密码啥的,非常恶心


呼出搜索栏,输入【计算机管理】,然后新建一个用户,设置好密码,最后加入管理员权限,别改自己的用户或者管理员的,win11的安全配置会让你欲哭无泪的,相信我


 runas /noprofile /user:LEMON-HP-LAPTOP\shell conda update -n base -c defaults conda


最后此计失败,还是在菜单里,右键后,有一个以管理员身份运行


conda create --name py310 python=3.10

conda activate py310

conda deactivate

===========================================================


3、cuda哈


developer.nvidia.com/cuda-downloads


选好,装好你平台的版本就行了


>>> import torch

>>> torch.cuda.is_available()

总是False,弄得我是很无语,好久不玩了才意识到是版本匹配问题


pytorch.org


去pytouch上去,看一下,最新支持的稳定版是11.7


developer.nvidia.com/cuda-11-7-1-download-archive


那我们就下载11.7.1的


2.5个G


conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia


安装完了以后重启,再装一下框架试试,否则真闹心


用nvidia-smi来看版本号


nvcc -V


报错:CondaVerificationError: The package for pytorch located at


解决:conda clean --all


出现的原因是上一次异常关闭了promt


===================================================


4、clone web ui


git clone https://ghproxy.com/github.com/AUTOMATIC1111/stable-diffusion-webui.git


===================================================


5、修改lanch.py


替换所有的“https://github.com”为“https://ghproxy.com/https://github.com”。这里也是利用Ghproxy进行代理,加速国内Git。 


=====================================================


6、安装python这边的依赖


pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ 


pip install -r requirements_versions.txt 


======================================================


7、降低显存占用


pip install xformer //如果不执行此条命令,启动Stable Diffusion时可能会出现错误。xformer还可以在后续使用中降低显卡占用。


=======================================================


8、解决虚拟环境问题


由于Stable Diffusion+WebUI使用的是Venv虚拟Python环境,完成上述操作后,我们还需更改Venv目录里的一个配置文件,以让Venv能使用环境外的第三方库。


cd .\venv

code .\pyvenv.cfg

将“include-system-site-packages = false”改为“include-system-site-packages = true”。


========================================================


9、我直接跳过了venv的配置


因为我是在conda里面的,所以属于脱了裤子放屁了


以上的顺序记住,一定需要是cuda-->conda-->conda pytorch环境-->git-->pip


最后:


python .\launch.py


那个bat文件里其实也就是最后启动launch.py


(py310) PS E:\sd\stable-diffusion-webui> python .\launch.py

Python 3.10.9 | packaged by conda-forge | (main, Jan 11 2023, 15:15:40) [MSC v.1916 64 bit (AMD64)]

Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39

Installing clip

Installing open_clip

Cloning Stable Diffusion into repositories\stable-diffusion-stability-ai...

Cloning Taming Transformers into repositories\taming-transformers...

Cloning K-diffusion into repositories\k-diffusion...

Cloning CodeFormer into repositories\CodeFormer...

Cloning BLIP into repositories\BLIP...

Installing requirements for CodeFormer

Installing requirements for Web UI

Launching Web UI with arguments:

No module 'xformers'. Proceeding without it.

No checkpoints found. When searching for checkpoints, looked at:

 - file E:\sd\stable-diffusion-webui\model.ckpt

 - directory E:\sd\stable-diffusion-webui\models\Stable-diffusion

Can't run without a checkpoint. Find and place a .ckpt or .safetensors file into any of those locations. The program will exit.

它会自动clone很多的依赖项目,但看来必须放一些模型在里面才能启动成功


把从盘里面的文件下载下来,7G呢,好大


下载好了两个,我就放在它说的那里了


E:\sd\stable-diffusion-webui\models\Stable-diffusion


==============================================================


best quality, ultra high res, (photorealistic:1.4), 1girl, brown blazer, black skirt, glasses, thighhighs, ((school uniform)), (upper body), (Kpop idol), (aegyo sal:1), (platinum blonde hair:1), ((puffy eyes)), looking at viewer, facing front, smiling, laughing, <lora:koreanDollLikeness_v10:0.66> 

Negative prompt: paintings, sketches, (worst quality:2), (low quality:2), (normal quality:2), lowres, normal quality, ((monochrome)), ((grayscale)), skin spots, acnes, skin blemishes, age spot, glan

Steps: 28, Sampler: DPM++ SDE Karras, CFG scale: 8, Seed: 308307804, Size: 512x768, Model hash: 95afa0d9ea, Model: chilloutmix_NiPrunedFp32, Clip skip: 2, ENSD: 31337


===================================================