用 Stable Diffusion 一類的 AI 算圖真的很有趣,可是總是要試好多次才能產出真正讓人滿意的圖。這麼一來,免費的額度就不夠了;怎麼辦?要嘛乖乖付錢課金,不然就只好乖乖花時間排隊囉。
其實,如果你的電腦效能夠好,也可以考慮在自己的機器上安裝一套 Stable Diffusion AI 來用,這樣愛算幾張就算幾張,愛用多久就用多久,很棒吧?
快速導覽
硬體需求
根據 StableDiffusion 官網 所寫,只要有 6G 以上 RAM 的 NVidia 顯卡都可以跑。不過根據 jimmy 實測,4G 的 1050ti 就可以順利運行了。(在我們這次使用的網頁介面實作項目 AUTOMATIC1111/stable-diffusion-webui 裡提到,2G 也有成功運行的報告)
安裝步驟
1. 下載並安裝 github for windows
這裡我們用 Windows 平台為範例來說明。
首先到 https://gitforwindows.org 下載 git for windows,並安裝。 ( 安裝過程中可取消與 Windows Exploer 整合 )
2. 下載並安裝 Stable Diffusion
a. 在 github 建立帳號
b. 到 https://github.com/AUTOMATIC1111/stable-diffusion-webui 專案頁面,按右上方的 Code 按鈕,複製專案網址
c. 在本機預定安裝位置建立資料夾,如 D:\AI
d. 啟動剛剛安裝的 git
e. 輸入 “cd /D/AI” ( 注意是 / 不是 \ )
f. 輸入 “git clone “,接著貼上步驟 b 複製的專案網址,按下 Enter 後等待專案複製完成
3. 下載並安裝 AI 模型
a. 在 Hugging Face 建立帳號
b. 到 https://huggingface.co/CompVis/stable-diffusion-v-1-4-original 下載 sd-v1-4-ckpt 檔案
c. 將 ckpt 檔放到 stable-diffusion-webui\models\Stable-diffusion\ 目錄中
( 在寫這篇文章的過程中,網路上又發佈了 1.5 版的模型,可以在這裡 下載,同時這個用來做 inpainting 的模型 建議也可以一併下載 。你可以把這些都放在同一個目錄中,使用時可以隨時切換)
4. 下載並安裝臉孔加強功能
a. 到 https://github.com/TencentARC/GFPGAN 頁面下方 下載 GFPGANv.14.pth
b. 將 pth 檔放到 stable-diffusion-webui\ 目錄中
5. 下載並安裝 Python
a. 到 https://www.python.org/downloads/release/python-3106 下載 Windows installer (64-bit) 版本
(這兩天 Python 的版本更新到了 3.11.0,但 AUTOMATIC1111 表示這個程式是基於 3.10.6 版開發的,除非你想給自己找麻煩,否則請不要使用其他版本 )
b. 安裝時記得勾選 Add Python.exe to PATH
6. 正式安裝 Stable Diffusion
點兩下 stable-diffusion-webui\ 目錄下的 webui-user.bat 來執行。
第一次執行會下載一些東西,要蠻久的,請耐心等候。
安裝完成後,用瀏覽器打開網址 127.0.0.1:7860 即可。
7. 錯誤處置
如果電腦效能不足導致執行發生錯誤,可以編輯 webui-user.bat,在 set COMMANDLINE_ARGS= 後面加上 “–opt-split-attention –precision full –no-half –medvram”,有機會可以解決問題
結論
到此 StableDiffusion WebUI 版本就安裝完畢了。下一篇我們會來看看怎麼使用它來創造有趣的影像。
60 comments
Having read those I thought it was extremely informative. I appreciate you spending some time and energy to put this article together.
I once again find myself spending way too much time both reading and posting comments. But so what, it was still worthwhile!
Thanks for your visit.
很詳細的介紹,目前程式運作方面照著做都沒問題,主要是完成後卡在關鍵字的輸入與模組的選擇,容易產生出許多奇奇怪怪的圖,期待您下次的更新能解決我的困擾
我也很常出現奇怪的圖,有時候就是得換一下關鍵字多試幾次 XD。
你好 我照您的方法 執行webui-user.bat 後 到這邊就卡住不動了
Loading weights [fe4efff1e1] from D:\AI\stable-diffusion-webui\models\Stable-diffusion\sd-v1-4.ckpt
Creating model from config: D:\AI\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Applying cross attention optimization (Doggettx).
Textual inversion embeddings loaded(0):
Model loaded in 3.8s (load weights from disk: 1.0s, create model: 0.4s, apply weights to model: 0.5s, apply half(): 0.6s, move model to device: 0.5s, load textual inversion embeddings: 0.8s).
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
請問我該怎麼做呢
接下來打開瀏覽器,在網址列輸入 127.0.0.1:7860 就可以開始使用了~
你好,抱歉打擾了
我卡在最後的
用瀏覽器打開網址 127.0.0.1:7860
無論用哪一種設定都是顯示127.0.0.1 拒絕連線
我該怎麼處理
這有很多可能,沒有實際看到我也沒辦法確定。
常見的情形你把 sb 視窗關掉了。
記得執行 webui-user.bat 啟動 stable diffusion 之後,終端機視窗不能關掉喲。
如果還不行再來討論吧!
有的,webui-user.bat全程都開著,
它在「To create a public link, set `share=True` in `launch()`.」之後出現了
Traceback (most recent call last):
File “D:\AI\stable-diffusion-webui\launch.py”, line 361, in
start()
File “D:\AI\stable-diffusion-webui\launch.py”, line 356, in start
webui.webui()
File “D:\AI\stable-diffusion-webui\webui.py”, line 232, in webui
app.add_middleware(GZipMiddleware, minimum_size=1000)
File “D:\AI\stable-diffusion-webui\venv\lib\site-packages\starlette\applications.py”, line 135, in add_middleware
raise RuntimeError(“Cannot add middleware after an application has started”)
RuntimeError: Cannot add middleware after an application has started
應用程序啟動後無法添加中間件
這要怎麼處理?
全部重來就沒問題了
謝謝Jimmy提供教學和回應提問
2. 下載並安裝 Stable Diffusion
a. 在 github 建立帳號
b. 到 https://github.com/AUTOMATIC1111/stable-diffusion-webui 專案頁面,按右上方的 Code 按鈕,複製專案網址
c. 在本機預定安裝位置建立資料夾,如 D:\AI
d. 啟動剛剛安裝的 git
e. 輸入 “cd /D/AI” ( 注意是 / 不是 \ )
f. 輸入 “git clone “,接著貼上步驟 b 複製的專案網址,按下 Enter 後等待專案複製完成
請問在步驟d 裡啟動的是那個應用程式?我試過GIT安裝檔案下的兩個程式,按教材建好D:\AI資料後輸入相應代碼都會提示系統找不到指定路徑。。。
也可以直接開一個終端機視窗,先切換到 AI 目錄。
然後直接輸入 git clone + 貼上網址這樣就可以了。
venv “D:\AI\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39
Installing clip
Traceback (most recent call last):
File “D:\AI\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “D:\AI\stable-diffusion-webui\launch.py”, line 278, in prepare_environment
run_pip(f”install {clip_package}”, “clip”)
File “D:\AI\stable-diffusion-webui\launch.py”, line 137, in run_pip
return run(f'”{python}” -m pip {args} –prefer-binary{index_url_line}’, desc=f”Installing {desc}”, errdesc=f”Couldn’t install {desc}”)
File “D:\AI\stable-diffusion-webui\launch.py”, line 105, in run
raise RuntimeError(message)
RuntimeError: Couldn’t install clip.
Command: “D:\AI\stable-diffusion-webui\venv\Scripts\python.exe” -m pip install git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1 –prefer-binary
Error code: 1
stdout: Collecting git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1
Cloning https://github.com/openai/CLIP.git (to revision d50d76daa670286dd6cacf3bcd80b5e4823fc8e1) to c:\users\wy\appdata\local\temp\pip-req-build-co7e8bbv
stderr: Running command git clone –filter=blob:none –quiet https://github.com/openai/CLIP.git ‘C:\Users\wy\AppData\Local\Temp\pip-req-build-co7e8bbv’
fatal: unable to access ‘https://github.com/openai/CLIP.git/’: Recv failure: Connection was reset
fatal: could not fetch 570a54198bb0d012a585c3999d5281c07cd339e9 from promisor remote
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with ‘git status’
and retry with ‘git restore –source=HEAD :/’
error: subprocess-exited-with-error
git clone –filter=blob:none –quiet https://github.com/openai/CLIP.git ‘C:\Users\wy\AppData\Local\Temp\pip-req-build-co7e8bbv’ did not run successfully.
exit code: 128
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
git clone –filter=blob:none –quiet https://github.com/openai/CLIP.git ‘C:\Users\wy\AppData\Local\Temp\pip-req-build-co7e8bbv’ did not run successfully.
exit code: 128
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
[notice] A new release of pip available: 22.2.1 -> 23.0
[notice] To update, run: D:\AI\stable-diffusion-webui\venv\Scripts\python.exe -m pip install –upgrade pip
請問運行webui-user.bat後出現這個是什麼情況呢?
A new release of pip available: 22.2.1 -> 23.0
好像是版本沒有跟上…
你試試把整個 AI 目錄移除,然後重新做一次試試看。
你好 請問我遇到下列狀況
是不是哪裡出錯了?
venv “C:\Program Files\Git\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39
Traceback (most recent call last):
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 272, in prepare_environment
run_python(“import torch; assert torch.cuda.is_available(), ‘Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'”)
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 129, in run_python
return run(f'”{python}” -c “{code}”‘, desc, errdesc)
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 105, in run
raise RuntimeError(message)
RuntimeError: Error running command.
Command: “C:\Program Files\Git\stable-diffusion-webui\venv\Scripts\python.exe” -c “import torch; assert torch.cuda.is_available(), ‘Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'”
Error code: 1
stdout:
stderr: Traceback (most recent call last):
File “”, line 1, in
AssertionError: Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
你機器有 Nvidia 的獨顯嗎?
你可以試著在 webui-user.bat 的 COMMANDLINE_ARGS= 後面加上 -skip-torch-cuda-test 試試。
不過沒有 GPU 的話跑起來會很慢很慢很慢
set COMMANDLINE_ARGS= -skip-torch-cuda-test–opt-split-attention –precision full –no-half –medvram
編輯後仍有狀況,是否可以請教?
venv “C:\Program Files\Git\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39
Traceback (most recent call last):
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 272, in prepare_environment
run_python(“import torch; assert torch.cuda.is_available(), ‘Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'”)
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 129, in run_python
return run(f'”{python}” -c “{code}”‘, desc, errdesc)
File “C:\Program Files\Git\stable-diffusion-webui\launch.py”, line 105, in run
raise RuntimeError(message)
RuntimeError: Error running command.
Command: “C:\Program Files\Git\stable-diffusion-webui\venv\Scripts\python.exe” -c “import torch; assert torch.cuda.is_available(), ‘Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check'”
Error code: 1
stdout:
stderr: Traceback (most recent call last):
File “”, line 1, in
AssertionError: Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
請按任意鍵繼續 . . .
2. 下載並安裝 Stable Diffusion
a. 在 github 建立帳號
b. 到 https://github.com/AUTOMATIC1111/stable-diffusion-webui 專案頁面,按右上方的 Code 按鈕,複製專案網址
c. 在本機預定安裝位置建立資料夾,如 D:\AI
d. 啟動剛剛安裝的 git
e. 輸入 “cd /D/AI” ( 注意是 / 不是 \ )
f. 輸入 “git clone “,接著貼上步驟 b 複製的專案網址,按下 Enter 後等待專案複製完成
请问e这一步是怎么做的?有点迷糊
沒關係,你就直接開一個終端機,cd 到想安裝的目錄下,直接輸入 git clone + 專案網址就行了。
4. 下載並安裝臉孔加強功能
a. 到 https://github.com/TencentARC/GFPGAN 頁面下方 下載 GFPGANv.14.pth
將 pth 檔放到 stable-diffusion-webui\ 目錄中
GFPGANv.14.pth 這個好像不在那裡面了?
是。
Stable Diffusion 的改版非常快,現在的版本已經把 GFPGAN 整合進去了。到 Settings->Face restoration 裡面選 GFPGAN,然後在生成圖片的頁面把 Restore faces 打勾,這樣下一次生成圖片的時候就會自動抓取需要的檔案下來了。
ps.就是因為改得太快,每次我想要寫新的版本的文,就發現又改得不一樣了,只好一直拖下去XD…
還是感謝你的文帶隊~期待你新一版的整合文~XDDD
您好,感谢教程。安装遇到一些问题,在启动webui-user.bat时会卡在installing gfpgan很久很久没有反应,但也不跳错,输入了你给的代码修改bat文件也没有用,能请教一下是什么问题嘛
新版本不需要手動安裝 GFPGAN,在後續執行時若有需要會自動下載。
抱歉,我下載的python版本是3.10.6,但執行批次檔時顯示以下這些訊息,該怎麼更改python版本呢?
INCOMPATIBLE PYTHON VERSION
This program is tested with 3.10.6 Python, but you have 3.9.7.
If you encounter an error with “RuntimeError: Couldn’t install torch.” message,
or any other error regarding unsuccessful package (library) installation,
please downgrade (or upgrade) to the latest version of 3.10 Python
and delete current Python and “venv” folder in WebUI’s directory.
You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3109/
Alternatively, use a binary release of WebUI: https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases
Use –skip-python-version-check to suppress this warning.
錯誤訊息顯示你的版本是3.9.7…請確認實際執行的 Phthon 版本
想請問一下,卡在Installing gfpgan不動要怎麼解決呢?
新版本不需要手動安裝 gfpgan 了,請參考上幾樓留言
遇上了以下問題, 請問可以幫忙解決嗎? 謝謝你!
venv “C:\Downloads\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch==1.13.1+cu117
ERROR: Exception:
Traceback (most recent call last):
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\base_command.py”, line 167, in exc_logging_wrapper
status = run_func(*args)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\req_command.py”, line 247, in wrapper
return func(self, options, args)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\commands\install.py”, line 369, in run
requirement_set = resolver.resolve(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py”, line 92, in resolve
result = self._result = resolver.resolve(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 172, in _add_to_criteria
if not criterion.candidates:
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\structs.py”, line 151, in __bool__
return bool(self._sequence)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 155, in __bool__
return any(self)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 143, in
return (c for c in iterator if id(c) not in self._incompatible_ids)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 47, in _iter_built
candidate = func()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py”, line 206, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 297, in __init__
super().__init__(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 162, in __init__
self.dist = self._prepare()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 231, in _prepare
dist = self._prepare_distribution()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 308, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 438, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 483, in _prepare_linked_requirement
local_file = unpack_url(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 165, in unpack_url
file = get_http_url(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 106, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py”, line 134, in __call__
resp = _http_get_download(self._session, link)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py”, line 117, in _http_get_download
resp = session.get(target_url, headers=HEADERS, stream=True)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 600, in get
return self.request(“GET”, url, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\session.py”, line 518, in request
return super().request(method, url, *args, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 587, in request
resp = self.send(prep, **send_kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 701, in send
r = adapter.send(request, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\adapter.py”, line 48, in send
cached_response = self.controller.cached_request(request)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\controller.py”, line 155, in cached_request
resp = self.serializer.loads(request, cache_data, body_file)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py”, line 95, in loads
return getattr(self, “_loads_v{}”.format(ver))(request, data, body_file)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py”, line 186, in _loads_v4
cached = msgpack.loads(data, raw=False)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 125, in unpackb
ret = unpacker._unpack()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 590, in _unpack
ret[key] = self._unpack(EX_CONSTRUCT)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 590, in _unpack
ret[key] = self._unpack(EX_CONSTRUCT)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 544, in _unpack
typ, n, obj = self._read_header()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 486, in _read_header
obj = self._read(n)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 403, in _read
ret = self._buffer[i : i + n]
MemoryError
[notice] A new release of pip available: 22.2.1 -> 23.0.1
[notice] To update, run: C:\Downloads\stable-diffusion-webui\venv\Scripts\python.exe -m pip install –upgrade pip
Traceback (most recent call last):
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 269, in prepare_environment
run(f'”{python}” -m {torch_command}’, “Installing torch and torchvision”, “Couldn’t install torch”, live=True)
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 89, in run
raise RuntimeError(f”””{errdesc or ‘Error running command’}.
RuntimeError: Couldn’t install torch.
Command: “C:\Downloads\stable-diffusion-webui\venv\Scripts\python.exe” -m pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 –extra-index-url https://download.pytorch.org/whl/cu117
Error code: 2
Press any key to continue . . .
試試 C:\Downloads\stable-diffusion-webui\venv\Scripts\python.exe -m pip install –upgrade pip 更新看看
感謝你的回覆. 但即使upgrade pip後, 還是出現一樣的錯誤:-
PS C:\Downloads\stable-diffusion-webui\venv\Scripts> python.exe -m pip install –upgrade pip
Requirement already satisfied: pip in c:\users\user\appdata\local\programs\python\python310\lib\site-packages (22.2.1)
Collecting pip
Using cached pip-23.0.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.2.1
Uninstalling pip-22.2.1:
Successfully uninstalled pip-22.2.1
Successfully installed pip-23.0.1
PS C:\Downloads\stable-diffusion-webui\venv\Scripts> cd ..
PS C:\Downloads\stable-diffusion-webui\venv> cd ..
PS C:\Downloads\stable-diffusion-webui> ./webui-user.bat
venv “C:\Downloads\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 3715ece0adce7bf7c5e9c5ab3710b2fdc3848f39
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu117
Collecting torch==1.13.1+cu117
ERROR: Exception:
Traceback (most recent call last):
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\base_command.py”, line 167, in exc_logging_wrapper
status = run_func(*args)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\cli\req_command.py”, line 247, in wrapper
return func(self, options, args)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\commands\install.py”, line 369, in run
requirement_set = resolver.resolve(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py”, line 92, in resolve
result = self._result = resolver.resolve(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 172, in _add_to_criteria
if not criterion.candidates:
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\resolvelib\structs.py”, line 151, in __bool__
return bool(self._sequence)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 155, in __bool__
return any(self)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 143, in
return (c for c in iterator if id(c) not in self._incompatible_ids)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 47, in _iter_built
candidate = func()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py”, line 206, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 297, in __init__
super().__init__(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 162, in __init__
self.dist = self._prepare()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 231, in _prepare
dist = self._prepare_distribution()
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 308, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 438, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 483, in _prepare_linked_requirement
local_file = unpack_url(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 165, in unpack_url
file = get_http_url(
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\operations\prepare.py”, line 106, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py”, line 134, in __call__
resp = _http_get_download(self._session, link)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\download.py”, line 117, in _http_get_download
resp = session.get(target_url, headers=HEADERS, stream=True)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 600, in get
return self.request(“GET”, url, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_internal\network\session.py”, line 518, in request
return super().request(method, url, *args, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 587, in request
resp = self.send(prep, **send_kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\requests\sessions.py”, line 701, in send
r = adapter.send(request, **kwargs)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\adapter.py”, line 48, in send
cached_response = self.controller.cached_request(request)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\controller.py”, line 155, in cached_request
resp = self.serializer.loads(request, cache_data, body_file)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py”, line 95, in loads
return getattr(self, “_loads_v{}”.format(ver))(request, data, body_file)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\cachecontrol\serialize.py”, line 186, in _loads_v4
cached = msgpack.loads(data, raw=False)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 123, in unpackb
unpacker.feed(packed)
File “C:\Downloads\stable-diffusion-webui\venv\lib\site-packages\pip\_vendor\msgpack\fallback.py”, line 381, in feed
self._buffer.extend(view)
MemoryError
[notice] A new release of pip available: 22.2.1 -> 23.0.1
[notice] To update, run: C:\Downloads\stable-diffusion-webui\venv\Scripts\python.exe -m pip install –upgrade pip
Traceback (most recent call last):
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 269, in prepare_environment
run(f'”{python}” -m {torch_command}’, “Installing torch and torchvision”, “Couldn’t install torch”, live=True)
File “C:\Downloads\stable-diffusion-webui\launch.py”, line 89, in run
raise RuntimeError(f”””{errdesc or ‘Error running command’}.
RuntimeError: Couldn’t install torch.
Command: “C:\Downloads\stable-diffusion-webui\venv\Scripts\python.exe” -m pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 –extra-index-url https://download.pytorch.org/whl/cu117
Error code: 2
Press any key to continue . . .
如果確定硬體規格都符合,還是有問題,那最後的方式就是把整個 stable diffusion 目錄砍掉,整個重裝一次看看。如果再不行,我也不知道怎麼辦了…
這個之前試過了,但還是不行。還是謝謝你的回覆。
不好意思沒幫上忙
在步驟6.要安裝時跑出如下錯誤
請問還有救嗎? 謝謝
return t.to(device, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 2.00 GiB total capacity; 1.71 GiB already allocated; 0 bytes free; 1.75 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
Stable diffusion model failed to load, exiting
請按任意鍵繼續 . . .
顯卡記憶卡不足
venv “F:\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8
Installing gfpgan
Traceback (most recent call last):
File “F:\stable-diffusion-webui\launch.py”, line 360, in
prepare_environment()
File “F:\stable-diffusion-webui\launch.py”, line 275, in prepare_environment
run_pip(f”install {gfpgan_package}”, “gfpgan”)
File “F:\stable-diffusion-webui\launch.py”, line 137, in run_pip
return run(f'”{python}” -m pip {args} –prefer-binary{index_url_line}’, desc=f”Installing {desc}”, errdesc=f”Couldn’t install {desc}”)
File “F:\stable-diffusion-webui\launch.py”, line 105, in run
raise RuntimeError(message)
RuntimeError: Couldn’t install gfpgan.
Command: “F:\stable-diffusion-webui\venv\Scripts\python.exe” -m pip install git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 –prefer-binary
Error code: 1
stdout: Collecting git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379
Cloning https://github.com/TencentARC/GFPGAN.git (to revision 8d2447a2d918f8eba5a4a01463fd48e45126a379) to c:\users\86139\appdata\local\temp\pip-req-build-0l38mdil
stderr: Running command git clone –filter=blob:none –quiet https://github.com/TencentARC/GFPGAN.git ‘C:\Users\86139\AppData\Local\Temp\pip-req-build-0l38mdil’
fatal: unable to access ‘https://github.com/TencentARC/GFPGAN.git/’: Recv failure: Connection was reset
fatal: could not fetch fa702eeacff13fe8475b0e102a8b8c37602f3963 from promisor remote
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with ‘git status’
and retry with ‘git restore –source=HEAD :/’
error: subprocess-exited-with-error
git clone –filter=blob:none –quiet https://github.com/TencentARC/GFPGAN.git ‘C:\Users\86139\AppData\Local\Temp\pip-req-build-0l38mdil’ did not run successfully.
exit code: 128
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
git clone –filter=blob:none –quiet https://github.com/TencentARC/GFPGAN.git ‘C:\Users\86139\AppData\Local\Temp\pip-req-build-0l38mdil’ did not run successfully.
exit code: 128
See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
可以看下这是怎么回事吗?该怎么办?
新版不用裝 gfpgan
你好 我在最後瀏覽器輸入網址的部分卡住了 會出現 127.0.0.1 拒絕連線 的頁面 我的webui-user 也沒有關 想請問一下要怎麼處裡呢?
ㄜ…你這樣問我也不知道,相關資訊太少了
venv “D:\AI BOT\webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 48a15821de768fea76e66f26df83df3fddf18f4b
Installing requirements for Web UI
Launching Web UI with arguments: –xformers
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Loading weights [7d7b896083] from D:\AI BOT\webui\models\Stable-diffusion\Counterfeit-V2.2.safetensors
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(0):
Model loaded in 546.7s (9.1s create model, 514.1s load weights).
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Traceback (most recent call last):
File “D:\AI BOT\webui\launch.py”, line 325, in
start()
File “D:\AI BOT\webui\launch.py”, line 320, in start
webui.webui()
File “D:\AI BOT\webui\webui.py”, line 224, in webui
app.add_middleware(GZipMiddleware, minimum_size=1000)
File “D:\AI BOT\webui\venv\lib\site-packages\starlette\applications.py”, line 135, in add_middleware
raise RuntimeError(“Cannot add middleware after an application has started”)
RuntimeError: Cannot add middleware after an application has started
請按任意鍵繼續 . . .
那請問這樣看得出問題ㄇ?
我也有發生一樣的問題,可以參考這邊
https://www.cnblogs.com/rulasann/p/9442420.html
我最後是在第三步驟,參考以下網站
https://blog.csdn.net/ambertian/article/details/70238020
修改IPV6優先級解決的
請問我最後安裝 stable diffusion 時最後好像失敗了,說我記憶體不足?
venv “E:\AI\StableDiffusion\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 0cc0ee1bcb4c24a8c9715f66cede06601bfc00c8
Installing requirements for Web UI
Launching Web UI with arguments:
No module ‘xformers’. Proceeding without it.
Loading weights [fe4efff1e1] from E:\AI\StableDiffusion\stable-diffusion-webui\models\Stable-diffusion\sd-v1-4.ckpt
Creating model from config: E:\AI\StableDiffusion\stable-diffusion-webui\configs\v1-inference.yaml
LatentDiffusion: Running in eps-prediction mode
Failed to create model quickly; will retry using slow method.
LatentDiffusion: Running in eps-prediction mode
loading stable diffusion model: RuntimeError
Traceback (most recent call last):
File “E:\AI\StableDiffusion\stable-diffusion-webui\webui.py”, line 111, in initialize
modules.sd_models.load_model()
File “E:\AI\StableDiffusion\stable-diffusion-webui\modules\sd_models.py”, line 406, in load_model
sd_model = instantiate_from_config(sd_config.model)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\util.py”, line 79, in instantiate_from_config
return get_obj_from_str(config[“target”])(**config.get(“params”, dict()))
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py”, line 550, in __init__
super().__init__(conditioning_key=conditioning_key, *args, **kwargs)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py”, line 92, in __init__
self.model = DiffusionWrapper(unet_config, conditioning_key)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py”, line 1314, in __init__
self.diffusion_model = instantiate_from_config(diff_model_config)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\util.py”, line 79, in instantiate_from_config
return get_obj_from_str(config[“target”])(**config.get(“params”, dict()))
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py”, line 700, in __init__
) if not use_spatial_transformer else SpatialTransformer(
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\attention.py”, line 297, in __init__
[BasicTransformerBlock(inner_dim, n_heads, d_head, dropout=dropout, context_dim=context_dim[d],
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\attention.py”, line 297, in
[BasicTransformerBlock(inner_dim, n_heads, d_head, dropout=dropout, context_dim=context_dim[d],
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\attention.py”, line 250, in __init__
self.ff = FeedForward(dim, dropout=dropout, glu=gated_ff)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\attention.py”, line 64, in __init__
) if not glu else GEGLU(dim, inner_dim)
File “E:\AI\StableDiffusion\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\attention.py”, line 49, in __init__
self.proj = nn.Linear(dim_in, dim_out * 2)
File “E:\AI\StableDiffusion\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\linear.py”, line 96, in __init__
self.weight = Parameter(torch.empty((out_features, in_features), **factory_kwargs))
RuntimeError: [enforce fail at ..\c10\core\impl\alloc_cpu.cpp:72] data. DefaultCPUAllocator: not enough memory: you tried to allocate 52428800 bytes.
請問這是甚麼問題呢?
問題就是你的記憶體不足呀
解決了,應該是我昨天邊工作邊安裝的關係,記憶體可能被其他軟體吃光了XD
请问“下一篇我們會來看看怎麼使用它來創造有趣的影像”,这个什么时候会有呢?
說實在我也不知道
嘛…什麼時候呢?
期待NovelAI的安裝教學
NovelAI 好像已經沒什麼聲量了
venv “D:\AI BOT\webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 48a15821de768fea76e66f26df83df3fddf18f4b
Installing requirements for Web UI
Launching Web UI with arguments: –xformers
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
Loading weights [7d7b896083] from D:\AI BOT\webui\models\Stable-diffusion\Counterfeit-V2.2.safetensors
Applying xformers cross attention optimization.
Textual inversion embeddings loaded(0):
Model loaded in 546.7s (9.1s create model, 514.1s load weights).
Running on local URL: http://127.0.0.1:7860
To create a public link, set `share=True` in `launch()`.
Traceback (most recent call last):
File “D:\AI BOT\webui\launch.py”, line 325, in
start()
File “D:\AI BOT\webui\launch.py”, line 320, in start
webui.webui()
File “D:\AI BOT\webui\webui.py”, line 224, in webui
app.add_middleware(GZipMiddleware, minimum_size=1000)
File “D:\AI BOT\webui\venv\lib\site-packages\starlette\applications.py”, line 135, in add_middleware
raise RuntimeError(“Cannot add middleware after an application has started”)
RuntimeError: Cannot add middleware after an application has started
請按任意鍵繼續 . . .
到貼上網址部分就變連線失敗了,請問這是什麼的問題?
根據 https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/7759 所說,安裝最新版本就好了…
Steps to reproduce the problem
Download latest version
Nothing special
我是一個零知識的新手都是爬了不同的文來一步步做,可能當中有點東西混亂了,能問一下JUMMY嗎,我安裝了GIT,PTTHON,但點兩下 stable-diffusion-webui\ 目錄下的 webui-user.bat 來執行時
顯示為Couldn’t launch python exit code: 9009,如果使用管理員身份執行則是沒有彈出任何東西
你可能沒有把 python 的路徑設好。安裝的時候,有一個 Add python.exe to PATH 你有打勾嗎?
Jimmy你好
請問如果安裝不成功是可以把D:\AI整個資料夾刪除掉就可以了嗎
我也是卡在最後面webui-user.bat那邊一直有錯誤訊息不知道哪有問題
感謝回覆
對!整個目錄刪除就可以了。
Jimmy你好,我的所有的安装都完成了,但在最后一步运行bat的时候一直显示
venv “F:\AI MODEL\stable-diffusion-webui-master\venv\Scripts\Python.exe”
No Python at ‘”C:\Users\Administrator\AppData\Local\Programs\Python\Python310\python.exe’
请问知道该怎么解决吗?
請確認步驟 5-b 有沒有勾選…
請教一下
我安裝完執行
最後出現這段訊息,您有碰過這個問題嗎?
有解決方法嗎?
venv “C:\Users\cmcarp\Documents\AI_Image\stable-diffusion-webui\venv\Scripts\Python.exe”
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Version: v1.9.4
Commit hash: feee37d75f1b168768014e4634dcb156ee649c05
Traceback (most recent call last):
File “C:\Users\cmcarp\Documents\AI_Image\stable-diffusion-webui\launch.py”, line 48, in
main()
File “C:\Users\cmcarp\Documents\AI_Image\stable-diffusion-webui\launch.py”, line 39, in main
prepare_environment()
File “C:\Users\cmcarp\Documents\AI_Image\stable-diffusion-webui\modules\launch_utils.py”, line 386, 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
請按任意鍵繼續 . . .
Torch is not able to use GPU; add –skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
你的機器有獨立顯卡嗎?