開啟新分頁支援定位功能 >>
實測:SDWebUI環境建置及參數設定,安裝套件 (extension) "AnimateDiff" 及相關模型 (Models) 配置,利用提示詞 (prompt) 生成影片。🫥
註:環境配置依個人電腦調整,詳於文末。
SDWebUI 生成影片-系統狀況
Stable Diffusion checkpoint (主模型):
creapromptLightning_creapromptUltimate6.safetensors
AnimatDiff Motion Module:
animatediffMotion_sdxlV10Beta.ckpt
512 x 512
Number of frames: 240
FPS: 24
512 x 512
Number of frames: 80
FPS: 8
1. 強制使用虛擬環境的 Python 啟動 webui
請嘗試用虛擬環境的 Python 直接啟動 launch.py:
bash
(venv_GPU) D:\sd_webui_GPU\webui> python launch.py
***webui-user.bat修改建議***
假設你的虛擬環境位於 D:\sd_webui_GPU\venv_GPU,修改後的 webui-user.bat 片段如下:
text
@echo off
REM 取消使用 system 內建 Python
REM set DIR=%~dp0system
REM 使用虛擬環境路徑
set VENV_DIR=%~dp0..\venv_GPU
REM 將虛擬環境的 Scripts 目錄加入 PATH,確保使用虛擬環境的 python 和 pip
set PATH=%VENV_DIR%\Scripts;%PATH%
REM 保留 git 路徑(假設 git 仍在 system\git\bin)
set DIR=%~dp0system
set PATH=%DIR%\git\bin;%PATH%
REM 取消指向 system\python 的其他變數
REM set PY_LIBS=%DIR%\python\Scripts\Lib;%DIR%\python\Scripts\Lib\site-packages
REM set PY_PIP=%DIR%\python\Scripts
REM set PIP_INSTALLER_LOCATION=%DIR%\python\get-pip.py
REM 其他環境變數保留
set SKIP_VENV=1
set TRANSFORMERS_CACHE=%DIR%\transformers-cache
REM 你可以在這裡呼叫啟動指令,例如:
REM python launch.py %*
說明
set VENV_DIR=%~dp0..\venv_GPU
%~dp0 是當前批次檔所在目錄(webui),..\venv_GPU 是上層目錄的虛擬環境資料夾。請依實際路徑調整。
把虛擬環境的 Scripts 目錄放在 PATH 前面,確保執行 python、pip 時會使用虛擬環境。
保留 git 路徑,因為 webui 可能需要 git。
移除指向 system\python 的路徑和變數,避免使用錯誤的 Python。
SKIP_VENV=1 表示跳過 webui 自動建立虛擬環境,因為你已經有自己的。
***安裝套件造成版本不兼容***
pip install torch==2.5.1+cu121 torchvision==0.20.1+cu121 torchaudio==2.5.1+cu121 --index-url https://download.pytorch.org/whl/cu121
這將強制從 PyTorch 官方 CUDA 121 源下載正確版本的包。
## GPU正常生成圖
```bat
set COMMANDLINE_ARGS=^
--models-dir "D:\SD\models" ^
--ckpt-dir "D:\SD\models\StableDiffusion" ^
--vae-dir "D:\SD\models\VAE" ^
--lora-dir "D:\SD\models\Lora" ^
--embeddings-dir "D:\SD\models\Embeddings" ^
--hypernetwork-dir "D:\SD\models\Hypernetworks" ^
--gfpgan-models-path "D:\SD\models\GFPGAN" ^
--esrgan-models-path "D:\SD\models\ESRGAN" ^
--clip-models-path "D:\SD\models\CLIP" ^
--codeformer-models-path "D:\SD\models\CodeFormer" ^
--scunet-models-path "D:\SD\models\SCUNet" ^
--swinir-models-path "D:\SD\models\SwinIR" ^
--xformers --opt-sdp-attention --no-half-vae --lowvram --always-batch-cond-uncond ^
--deepdanbooru --autolaunch --theme dark --disable-safe-unpickle