amd顯卡在wsl環(huán)境下配置stable-diffusion-webui

環(huán)境為 wsl2 + openEule-22.09,顯卡為農(nóng)企的rx5700
只能說能用~
安裝git、python軟件包
sudo dnf install -y git python
下載stable-diffusion-webui到本地
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && cd ./stable-diffusion-webui
安裝Miniconda
下載Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
使用Miniconda
bash Miniconda3-latest-Linux-x86_64.sh
初始化完畢后輸入conda -V 查看是否成功安裝,若提示命令不存在,可執(zhí)行 source ~/.bashrc 刷新當前環(huán)境變量
配置stable-diffusion-webui環(huán)境
創(chuàng)建stable-diffusion-webui環(huán)境
conda create -n stable-diffusion-webui python=3.10
進入stable-diffusion-webui環(huán)境
conda activate stable-diffusion-webui
配置pip包管理器的源地址
vi ~/.config/pip/pip.conf
添加以下內(nèi)容
[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com
安裝環(huán)境依賴
conda install numpy==1.23.5 conda install pytorch=1.13.1 cpuonly -c pytorch pip install torch-directml==0.1.13.1dev230301 gfpgan clip pip install -r requirements.txt
可能會遇到提示pip版本過低,可執(zhí)行pip install --upgrade pip升級
修改部分代碼,使其支持directml
找到 ./modules/devices.py 里的?
def has_maps() -> bool:
,在上面添加如下代碼def has_dml() -> bool:
?return True
同樣是 ./modules/devices.py 里的?
def get_optimal_device_name()
,在代碼內(nèi)部的?if has_maps():
?上面添加if has_dml(): ?return "dml"
同樣是 ./modules/devices.py 里的?
def get_optimal_device_name()
,在代碼內(nèi)部添加if get_optimal_device_name() == "dml": ?import torch_directml ?return torch_directml.device()
找到 ./modules/sd_models.py 里的?
device = map_location or shared.weight_load_location or devices.get_optimal_device_name()
,修改為device = map_location or shared.weight_load_location or devices.get_optimal_device()
開啟stable-diffusion-webui應用服務
python .\launch.py --skip-torch-cuda-test --lowvram --precision full --no-half
首次運行可能還需要安裝部分依賴,請靜候
在部署中遇到的一些錯誤
代碼縮進不要用空格
安裝環(huán)境依賴要在
conda activate stable-diffusion-webui
之后報libGL.so.1缺失,執(zhí)行
pip install opencv-python-headless
部分內(nèi)容參考自?
