目錄
準(zhǔn)備工作
主機電腦配置檢查
安裝以下軟件
Python
Git
下載stable-diffusion-webui倉庫
根據(jù)顯卡屬性安裝CUDA
2.下載stable diffusion的訓(xùn)練模型
啟動
問題處理
模型加載問題
這是啟動后界面
以下是運行時的系統(tǒng)狀態(tài)截圖
準(zhǔn)備工作
主機電腦配置檢查
需要16G內(nèi)存,8G顯存(網(wǎng)上說是6G就夠,不過跑出來圖片像素會低,顯存越大畫質(zhì)也越好)
CPU要求不高,我的配置是 i5-8400
顯卡,咱用的是 2060s ,一千多點買的二手顯卡
內(nèi)存是32G (16G就可以)
電源600W (400W也能跑,不過怕功率不夠)[電源功率= (顯卡功率+CPU+100) * 1.5]
主板是 微星B360M
系統(tǒng)是win10
安裝以下軟件
Python
從官網(wǎng)下載Python,選擇Windows Installer (64-bit)版本并安裝(python 3.10 (必須是這個版本))
以下命令查看python是否安裝成功
python --version
Git
.下載Git for Windows并安裝
下載stable-diffusion-webui倉庫
打開git bash? 選擇合適的文件夾路徑拉取項目代碼
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
根據(jù)顯卡屬性安裝CUDA
進入 PyTorch
根據(jù)自己cuda版本 找到pytorch下載版本的pip命令,比如我的是 11.7
以前版本的torch下載命令地址
Previous PyTorch Versions | PyTorch
2.下載stable diffusion的訓(xùn)練模型
4. 從Hugging Face下載v2-1_768-ema-pruned.ckpt。 文件很大,因此需要一段時間才能下載完成
地址:https://huggingface.co/CompVis/stable-diffusion-v-1-4-original/tree/main
下載好之后,請把模型放置在sd-webui的models/stable-diffusion目錄下
啟動
點擊stable-diffusion-webui文件夾下的webui.bat啟動程序
問題處理
啟動問題
以上問題的原因是pytorch沒安裝好,或是版本不對應(yīng),獲取不到GPU
安裝適合CUDA版本的torch
Previous PyTorch Versions | PyTorch
安裝正確的torch后,可以用以下代碼測試是否torch能用上GPU
import torch
print(torch.__version__)
print(torch.cuda.is_available())
模型加載問題
異常內(nèi)容:
Stable diffusion model failed to load
Loading weights [ad2a33c361] from D:\learnAndTrain\AI\project\stable-diffusion-webui\models\Stable-diffusion\v2-1_768-ema-pruned.ckpt
NansException: A tensor with all NaNs was produced in Unet. This could be either because there's not enough precision to represent the picture, or because your video card does not support half type. Try setting the "Upcast cross attention layer to float32" option in Settings > Stable Diffusion or using the --no-half commandline argument to fix this. Use --disable-nan-check commandline argument to disable this check.
Time taken:?0.35s
Torch active/reserved: 3241/3642 MiB,?Sys VRAM: 5970/8192 MiB (72.88%)
出現(xiàn)以上問題需要加啟動參數(shù)
用記事本打開webui.bat,找到這一行
%PYTHON%?launch.py?%*
加三個參數(shù),按我的改
%PYTHON%?launch.py?%* --disable-nan-check --precision full --no-half
第1個參數(shù)不改,stable diffusion跑不起來,第二個參數(shù)和第三個參數(shù)不加,圖像生成后就是黑屏。
改完,再運行webui.bat,出現(xiàn)這個就對了:(劃重點:127.0.0.1:7860,在瀏覽器里跑)
這是啟動后界面
以下是運行時的系統(tǒng)狀態(tài)截圖
附幾張生成的圖片(咒語還不太會,圖片略丑):文章來源:http://www.zghlxwxcb.cn/news/detail-633898.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-633898.html
到了這里,關(guān)于本地開啟stable diffusion web-ui體驗AIGC文生圖,圖生圖的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!