Stable Diffusion 會需要用到pytorch ,你的電腦會需要安裝 pytorch https://pytorch.org/get-started/locally
請依照你的cuda版本來安裝,cuda版本可以執行nvidia-smi 來找到你現在顯卡安裝的cuda版本
如果安裝好上面的pytorch後可以測試是否成功
C:\Users\User>python
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>import torch
>>>torch.cuda.is_available()
True
出現true就是正確了。
但是如果跑webui-user.bat 還是會失敗,顯示
venv "C:\Users\User\Desktop\Stable Diffusion\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.10.1
Commit hash: 82a973c04367123ae98bd9abdf80d9eda9b910e2
Traceback (most recent call last):
File "C:\Users\User\Desktop\Stable Diffusion\stable-diffusion-webui\launch.py", line 48, in
main()
File "C:\Users\User\Desktop\Stable Diffusion\stable-diffusion-webui\launch.py", line 39, in main
prepare_environment()
File "C:\Users\User\Desktop\Stable Diffusion\stable-diffusion-webui\modules\launch_utils.py", line 387, 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
請按任意鍵繼續 . . .
有一種可能,就是你的Stable Diffusion虛擬環境內沒有pytorch
你要執行stable-diffusion-webui\venv\Scripts\ 目錄下的activate.bat
這時候他會幫你切換到虛擬環境下的cmd 然後再去安裝pytorch即可
如指令pip3 install torch torchvision torchaudio –index-url https://download.pytorch.org/whl/cu126
執行完畢後就可以去開啟webui.bat 這時候就會出現網頁http://127.0.0.1:7861/ 給你玩了