前言
主要的安裝步驟是參考B站播放量第一的視頻,但是那位阿婆主應該是沒有編程經驗,只強調使用3.10
,而python最新版本是3.11
。
理論上來說,只是一個小版本的不同,應該是可以安裝成功了。自己摸索了下,挺費勁了,故記錄下,支持最新版python3.11
的安裝經驗。
這里建議先看下B站視頻:【B站第一套系統(tǒng)的AI繪畫課!零基礎學會Stable Diffusion,這絕對是你看過的最容易上手的AI繪畫教程 | SD WebUI 保姆級攻略】
這里我假設你們已經自己安裝好了python、git。
這里我假設你們已經自己安裝好了python、git。
這里我假設你們已經自己安裝好了python、git。
畢竟CSDN是編程人員的論壇,這點小事,應該沒問題。
安裝步驟
更新window顯卡驅動
這里為了后續(xù)安裝的順利,我們需要更新下電腦的顯卡驅動,如果最近已經更新過的,就不用更新了。
按win+R,輸入devmgmt.msc
,彈出下框。
上圖是我的顯卡驅動。
這時我們再去官網下載最新驅動:https://www.nvidia.cn/Download/index.aspx
之后,點擊exe文件,進行安裝即可。
下載 Stable Diffusion 代碼
執(zhí)行:
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
修改launch_utils.py文件
路徑:
stable-diffusion-webui-master\modules\launch_utils.py
搜索關鍵字:xformers
,找到platform.python_version().startswith
,改為3.11
修改webui-user.bat文件
路徑:
stable-diffusion-webui-master\modules\webui-user.bat
主要是修改:COMMANDLINE_ARGS
@echo off
set PYTHON=
set GIT=
set VENV_DIR=
set COMMANDLINE_ARGS=--no-half-vae --disable-nan-check --skip-python-version-check --force-enable-xformers --xformers
call webui.bat
配置git代理
我的代理:
所以你也需要根據(jù)自己的代理來修改下面的端口號。
git config --global https.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
假設想去掉代理:
# 恢復
git config --global --unset http.proxy
git config --global --unset https.proxy
include-system-site-packages 這個參數(shù)可以設置是否開啟“引用系統(tǒng)中的模塊”的功能。如果開啟了,那么當你就可以直接使用系統(tǒng)中已經裝過的第三方模塊。(但是你在虛擬環(huán)境下裝的模塊就不能被其他地方的程序使用)
設置pip下載源、代理、升級
# 設置源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com
設置代理,路徑:C:\Users\yutao\AppData\Roaming\pip\pip.ini
[global]
index-url = https://mirrors.aliyun.com/pypi/simple
proxy = http://127.0.0.1:7890
[install]
trusted-host = mirrors.aliyun.com
升級pip
,在cmd中:
C:\Users\yutao>python.exe -m pip install --upgrade pip
mac電腦:
# 查看配置文件讀取順序
MacBook-Pro:openai yutao$ pip config list -v
For variant 'global', will try loading '/Library/Application Support/pip/pip.conf'
For variant 'user', will try loading '/Users/yutao/.pip/pip.conf'
For variant 'user', will try loading '/Users/yutao/.config/pip/pip.conf'
For variant 'site', will try loading '/Users/yutao/.pyenv/versions/3.10.9/pip.conf'
在/Users/yutao/.pip/pip.conf
上新建文件,填入上面的配置。
安裝cuda
在cmd命令中,執(zhí)行:nvidia-smi
,查看本機適合的cuda version版本
cuda各版本下載地址
下載下來是一個exe文件,如:cuda_12.2.2_537.13_windows.exe
文件。
點擊安裝即可。一切默認。
下載大模型
可以先看視頻了解下,都有哪些模型:
【AI繪畫模型新手包!“畫風”自由切換,有哪些你不知道的模型使用技巧? | 零基礎入門Stable Diffusion的保姆級新手教程 | SD模型下載方式與推薦】
我下載的是guofeng3
下載后,存放路徑:
如果出現(xiàn)pip已經下載的模塊,但是識別不了的情況下,修改pyvenv.cfg文件
路徑E:\openai\project\stable-diffusion-webui\venv
,這個需要啟動webui-user.bat
才會產生。
E:\openai\project\stable-diffusion-webui\venv
這個venv
是需要運行webui-user.bat
文件后才會產生的。
下面是我的pyvenv.cfg
文件內容
home = D:\Program Files\Python
include-system-site-packages = true
version = 3.11.2
executable = D:\Program Files\Python\python.exe
command = D:\Program Files\Python\python.exe -m venv E:\openai\project\stable-diffusion-webui\venv
include-system-site-packages
這個參數(shù)可以設置是否開啟“引用系統(tǒng)中的模塊”的功能。如果開啟了,那么我們就可以直接使用系統(tǒng)中已經裝過的第三方模塊。(但是你在虛擬環(huán)境下裝的模塊就不能被其他地方的程序使用)
雙擊運行webui-user.bat文件
該文件是以后每次運行啟動文件。
啟動時,遇到的各種問題,下面會單獨講解。
啟動頁命令框里,看到:Running on local URL: http://127.0.0.1:7860
,表示啟動成功。
將http://127.0.0.1:7860
,放入瀏覽器里執(zhí)行,就OK了。
頁面長這個樣子:
以后每次運行程序:雙擊運行webui-user.bat文件即可。
遇到的問題
pip 安裝失敗,萬能解決辦法 – 手動安裝
正常情況下,當我們遇到pip安裝失敗的情況下,單獨執(zhí)行,下面的語句是沒有問題的:
# 這種總是安裝失敗時
pip install https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip --prefer-binary
但是如果遇到總是安裝失敗的情況下,這時,我們就需要手動安裝了:
比如,我們現(xiàn)在遇到安裝:antlr4-python3-runtime==4.9.3
無法自動安裝的情況。
這時,我們就去官網下載:https://pypi.org/project/antlr4-python3-runtime/4.9.3/
把文件下載下來:
然后將下載下來的包,解壓到:E:\openai\project\stable-diffusion-webui\venv\Scripts\
路徑下。
接著在cmd中執(zhí)行python3 setup.py build install
:
具體我執(zhí)行的命令:
E:\openai\project\stable-diffusion-webui\venv\Scripts\antlr4-python3-runtime-4.9.3>e:\openai\project\stable-diffusion-webui\venv\Scripts\python.exe setup.py build install
RuntimeError: Couldn’t install torch.
錯誤信息:
E:\openai\project\stable-diffusion-webui\venv\Scripts\python.exe: No module named pip
Traceback (most recent call last):
File "E:\openai\project\stable-diffusion-webui\launch.py", line 39, in <module>
main()
File "E:\openai\project\stable-diffusion-webui\launch.py", line 30, in main
prepare_environment()
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 311, in prepare_environment
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 113, in run
raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "E:\openai\project\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
Error code: 1
解決辦法
# 在cmd窗口中執(zhí)行如下命令即可:
pip install torch==2.0.1 torchvision==0.15.2 --extra-index-url https://download.pytorch.org/whl/cu118
RuntimeError: Torch is not able to use GPU;
錯誤信息:
venv "E:\openai\project\stable-diffusion-webui\venv\Scripts\Python.exe"
fatal: No names found, cannot describe anything.
Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)]
Version: 1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Traceback (most recent call last):
File "E:\openai\project\stable-diffusion-webui\launch.py", line 39, in <module>
main()
File "E:\openai\project\stable-diffusion-webui\launch.py", line 30, in main
prepare_environment()
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 314, in prepare_environment
raise RuntimeError(
RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
解決辦法
這說明需要安裝cuda
。上面有安裝教程。
RuntimeError: Couldn’t install gfpgan.
錯誤信息:
Version: 1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Installing gfpgan
Traceback (most recent call last):
File "E:\openai\project\stable-diffusion-webui\launch.py", line 39, in <module>
main()
File "E:\openai\project\stable-diffusion-webui\launch.py", line 30, in main
prepare_environment()
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 320, in prepare_environment
run_pip(f"install {gfpgan_package}", "gfpgan")
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 136, in run_pip
return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=live)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 113, in run
raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install gfpgan.
Command: "E:\openai\project\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip --prefer-binary
Error code: 1
stdout: Collecting https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip
Downloading https://github.com/TencentARC/GFPGAN/archive/8d2447a2d918f8eba5a4a01463fd48e45126a379.zip (6.0 MB)
---------------------------------------- 6.0/6.0 MB 43.6 kB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
stderr: ERROR: No .egg-info directory found in C:\Users\yutao\AppData\Local\Temp\pip-pip-egg-info-6ubqppke
解決辦法
本質上就是連不上網,所以需要開代理,并配置代理,只要按照上面來,就沒問題。
RuntimeError: Couldn’t install clip.
Version: 1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Installing clip
Traceback (most recent call last):
File "E:\openai\project\stable-diffusion-webui\launch.py", line 39, in <module>
main()
File "E:\openai\project\stable-diffusion-webui\launch.py", line 30, in main
prepare_environment()
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 323, in prepare_environment
run_pip(f"install {clip_package}", "clip")
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 136, in run_pip
return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=live)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "E:\openai\project\stable-diffusion-webui\modules\launch_utils.py", line 113, in run
raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install clip.
Command: "E:\openai\project\stable-diffusion-webui\venv\Scripts\python.exe" -m pip install https://ghproxy.com/https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip --prefer-binary
Error code: 1
stdout: Collecting https://ghproxy.com/https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip
Downloading https://ghproxy.com/https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip (4.3 MB)
---------------------------------------- 4.3/4.3 MB 2.3 MB/s eta 0:00:00
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'done'
stderr: ERROR: No .egg-info directory found in C:\Users\yutao\AppData\Local\Temp\pip-pip-egg-info-w8i73o1w
解決辦法
先試試:
pip install https://ghproxy.com/https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip --prefer-binary
如果不行,就手動安裝:
- https://github.com/openai/CLIP 下載
- 把壓縮文件解壓到
xxx\stable-diffusion-webui\venv\Scripts
- 打開clip-main文件夾,在上方紅框的路徑地址欄里輸入CMD,進入clip-main路徑下的cmd命令提示符界面
- cmd中執(zhí)行:python.exe setup.py build install
特別注意,python.exe要是你自己的路徑。
stable diffusion本地安裝部署提示clip安裝失敗的解決方法
下載:https://github.com/openai/CLIP
輸入xxx\stable-diffusion-webui\venv\Scripts\python.exe -m pip install ftfy regex tqdm 安裝clip依賴
輸入xxx\stable-diffusion-webui\venv\Scripts\python.exe setup.py build install
安裝jsonmerge==1.8.0 報錯
這種情況下,就執(zhí)行pip install jsonmerge
安裝最新版即可。
安裝好后,注意cmd中打印的版本信息,比如我安裝完后的版本號jsonmerge==1.9.2
;
這時需要修改下文件:
將jsonmerge==1.8.0
修改為:jsonmerge==1.9.2
jsonmerge==1.9.2
參考地址:
Python pip 源設置成國內源,阿里云源,清華大學源
https://civitai.com/models/10415/3-guofeng3
Antlr4-python3-runtime在ubuntu上的安裝
stable diffusion本地安裝部署提示clip安裝失敗的解決方法
打開stable diffusion webui時,提示缺少clip或clip安裝不上的解決方案(windows下的操作)文章來源:http://www.zghlxwxcb.cn/news/detail-698137.html
Windows下使用Git部署Stable-Diffusion-Webui文章來源地址http://www.zghlxwxcb.cn/news/detail-698137.html
到了這里,關于【Stable Diffusion安裝】支持python3.11 window版的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!