官网
Stable Diffusion官网
Stability AI
官方github
GitHub - Stability-AI/stablediffusion: High-Resolution Image Synthesis with Latent Diffusion Models
stable-diffusion-webui github
https://github.com/AUTOMATIC1111/stable-diffusion-webui
安装
下载stable-diffusion-webui
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
nvidia驱动
NVIDIA-Linux-x86_64-535.54.03.run cuda_12.2.0_535.54.03_linux.run下载地址_hkNaruto的博客-CSDN博客
安装conda
wget https://mirrors.bfsu.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
打开一个新终端,配置源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --set show_channel_urls yes
编辑~/.condarc 内容如下即可。
创建Python 3.10.6环境
conda create -n stable-diffusion-webui python=3.10.6
(base) yeqiang@yeqiang-MS-7B23:~/Downloads$ conda create -n stable-diffusion-webui python=3.10.6
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/yeqiang/miniconda3/envs/stable-diffusion-webui
added / updated specs:
- python=3.10.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | conda_forge 3 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
_openmp_mutex-4.5 | 2_gnu 23 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
bzip2-1.0.8 | h7f98852_4 484 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ca-certificates-2023.5.7 | hbcca054_0 145 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ld_impl_linux-64-2.40 | h41732ed_0 688 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libffi-3.4.2 | h7f98852_5 57 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgcc-ng-13.1.0 | he5830b7_0 758 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libgomp-13.1.0 | he5830b7_0 409 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libnsl-2.0.0 | h7f98852_0 31 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libsqlite-3.42.0 | h2797004_0 809 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libuuid-2.38.1 | h0b41bf4_0 33 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
libzlib-1.2.13 | hd590300_5 60 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
ncurses-6.4 | hcb278e6_0 860 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
openssl-3.1.1 | hd590300_1 2.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
pip-23.1.2 | pyhd8ed1ab_0 1.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
python-3.10.6 |ha86cf86_0_cpython 29.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
readline-8.2 | h8228510_1 275 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
setuptools-68.0.0 | pyhd8ed1ab_0 453 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tk-8.6.12 | h27826a3_0 3.3 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
tzdata-2023c | h71feb2d_0 115 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
wheel-0.40.0 | pyhd8ed1ab_0 54 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
xz-5.2.6 | h166bdaf_0 409 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
------------------------------------------------------------
Total: 41.6 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex anaconda/cloud/conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex anaconda/cloud/conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
bzip2 anaconda/cloud/conda-forge/linux-64::bzip2-1.0.8-h7f98852_4
ca-certificates anaconda/cloud/conda-forge/linux-64::ca-certificates-2023.5.7-hbcca054_0
ld_impl_linux-64 anaconda/cloud/conda-forge/linux-64::ld_impl_linux-64-2.40-h41732ed_0
libffi anaconda/cloud/conda-forge/linux-64::libffi-3.4.2-h7f98852_5
libgcc-ng anaconda/cloud/conda-forge/linux-64::libgcc-ng-13.1.0-he5830b7_0
libgomp anaconda/cloud/conda-forge/linux-64::libgomp-13.1.0-he5830b7_0
libnsl anaconda/cloud/conda-forge/linux-64::libnsl-2.0.0-h7f98852_0
libsqlite anaconda/cloud/conda-forge/linux-64::libsqlite-3.42.0-h2797004_0
libuuid anaconda/cloud/conda-forge/linux-64::libuuid-2.38.1-h0b41bf4_0
libzlib anaconda/cloud/conda-forge/linux-64::libzlib-1.2.13-hd590300_5
ncurses anaconda/cloud/conda-forge/linux-64::ncurses-6.4-hcb278e6_0
openssl anaconda/cloud/conda-forge/linux-64::openssl-3.1.1-hd590300_1
pip anaconda/cloud/conda-forge/noarch::pip-23.1.2-pyhd8ed1ab_0
python anaconda/cloud/conda-forge/linux-64::python-3.10.6-ha86cf86_0_cpython
readline anaconda/cloud/conda-forge/linux-64::readline-8.2-h8228510_1
setuptools anaconda/cloud/conda-forge/noarch::setuptools-68.0.0-pyhd8ed1ab_0
tk anaconda/cloud/conda-forge/linux-64::tk-8.6.12-h27826a3_0
tzdata anaconda/cloud/conda-forge/noarch::tzdata-2023c-h71feb2d_0
wheel anaconda/cloud/conda-forge/noarch::wheel-0.40.0-pyhd8ed1ab_0
xz anaconda/cloud/conda-forge/linux-64::xz-5.2.6-h166bdaf_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate stable-diffusion-webui
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) yeqiang@yeqiang-MS-7B23:~/Downloads$
注意:
以下方式
sudo apt update
sudo apt install python3 python3-venv
可能由于本机手动编译安装过其他版本Python而冲突,还是conda方便。
conda查看已安装的虚拟环境
conda info --envs
激活
conda activate stable-diffusion-webui
查看版本
pip国内清华源
mkdir ~/.pip
vim ~/.pip/pip.conf
输入内容
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn
安装依赖(自动)
conda activate stable-diffusion-webui
cd ~/Downloads/ai/stable-diffusion-webui
./webui.sh
日志
(stable-diffusion-webui) yeqiang@yeqiang-MS-7B23:~/Downloads/ai/stable-diffusion-webui$ ./webui.sh
################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################
################################################################
Running on yeqiang user
################################################################
################################################################
Repo already cloned, using it as install directory
################################################################
################################################################
Create and activate python venv
################################################################
################################################################
Launching launch.py...
################################################################
Cannot locate TCMalloc (improves CPU memory usage)
Python 3.10.6 | packaged by conda-forge | (main, Aug 22 2022, 20:36:39) [GCC 10.4.0]
Version: v1.4.0
Commit hash: 394ffa7b0a7fff3ec484bcd084e673a8b301ccc8
Installing torch and torchvision
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple, https://download.pytorch.org/whl/cu118
Collecting torch==2.0.1
Using cached https://download.pytorch.org/whl/cu118/torch-2.0.1%2Bcu118-cp310-cp310-linux_x86_64.whl (2267.3 MB)
Collecting torchvision==0.15.2
Using cached https://download.pytorch.org/whl/cu118/torchvision-0.15.2%2Bcu118-cp310-cp310-linux_x86_64.whl (6.1 MB)
Collecting triton==2.0.0
Using cached https://download.pytorch.org/whl/triton-2.0.0-1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (63.3 MB)
Collecting networkx
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a8/05/9d4f9b78ead6b2661d6e8ea772e111fc4a9fbd866ad0c81906c11206b55e/networkx-3.1-py3-none-any.whl (2.1 MB)
Collecting typing-extensions
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ec/6b/63cc3df74987c36fe26157ee12e09e8f9db4de771e0f3404263117e75b95/typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting filelock
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/00/45/ec3407adf6f6b5bf867a4462b2b0af27597a26bd3cd6e2534cb6ab029938/filelock-3.12.2-py3-none-any.whl (10 kB)
Collecting sympy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d2/05/e6600db80270777c4a64238a98d442f0fd07cc8915be2a1c16da7f2b9e74/sympy-1.12-py3-none-any.whl (5.7 MB)
Collecting jinja2
Using cached https://download.pytorch.org/whl/Jinja2-3.1.2-py3-none-any.whl (133 kB)
Collecting requests
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/70/8e/0e2d847013cb52cd35b38c009bb167a1a26b2ce6cd6965bf26b47bc0bf44/requests-2.31.0-py3-none-any.whl (62 kB)
Collecting numpy
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/77/03/79b0bfc6e9dcd5eabbb17a714a2480ad3f932063eb8b39f6116ac207d5e3/numpy-1.25.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.6 MB)
Collecting pillow!=8.3.*,>=5.3.0
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3d/36/e78f09d510354977e10102dd811e928666021d9c451e05df962d56477772/Pillow-10.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.4 MB)
Collecting lit
Using cached lit-16.0.6-py3-none-any.whl
Collecting cmake
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/b5/3a/0d5889762ec82d3c556cfab075e6cdbca06dc5cff55436950152d63bb194/cmake-3.26.4-py2.py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (24.0 MB)
Collecting MarkupSafe>=2.0
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/12/b3/d9ed2c0971e1435b8a62354b18d3060b66c8cb1d368399ec0b9baa7c0ee5/MarkupSafe-2.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting urllib3<3,>=1.21.1
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/8a/03/ad9306a50d05c166e3456fe810f33cee2b8b2a7a6818ec5d4908c4ec6b36/urllib3-2.0.3-py3-none-any.whl (123 kB)
Collecting certifi>=2017.4.17
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9d/19/59961b522e6757f0c9097e4493fa906031b95b3ebe9360b2c3083561a6b4/certifi-2023.5.7-py3-none-any.whl (156 kB)
Collecting idna<4,>=2.5
Using cached https://download.pytorch.org/whl/idna-3.4-py3-none-any.whl (61 kB)
Collecting charset-normalizer<4,>=2
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cc/f6/21a66e524658bd1dd7b89ac9d1ee8f7823f2d9701a2fbc458ab9ede53c63/charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (199 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 199.3/199.3 kB 367.5 kB/s eta 0:00:00
Collecting mpmath>=0.19
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl (536 kB)
Installing collected packages: mpmath, lit, cmake, urllib3, typing-extensions, sympy, pillow, numpy, networkx, MarkupSafe, idna, filelock, charset-normalizer, certifi, requests, jinja2, triton, torch, torchvision
Successfully installed MarkupSafe-2.1.3 certifi-2023.5.7 charset-normalizer-3.1.0 cmake-3.26.4 filelock-3.12.2 idna-3.4 jinja2-3.1.2 lit-16.0.6 mpmath-1.3.0 networkx-3.1 numpy-1.25.0 pillow-10.0.0 requests-2.31.0 sympy-1.12 torch-2.0.1+cu118 torchvision-0.15.2+cu118 triton-2.0.0 typing-extensions-4.7.1 urllib3-2.0.3
[notice] A new release of pip available: 22.2.1 -> 23.1.2
[notice] To update, run: pip install --upgrade pip
Traceback (most recent call last):
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/launch.py", line 38, in <module>
main()
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/launch.py", line 29, in main
prepare_environment()
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/modules/launch_utils.py", line 268, 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
故障处理
RuntimeError: Torch is not able to use GPU; add --skip-torch-cuda-test to COMMANDLINE_ARGS variable to disable this check
Traceback (most recent call last):
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/launch.py", line 38, in <module>
main()
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/launch.py", line 29, in main
prepare_environment()
File "/home/yeqiang/Downloads/ai/stable-diffusion-webui/modules/launch_utils.py", line 268, 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-webui) yeqiang@yeqiang-MS-7B23:~/Downloads/ai/stable-diffusion-webui$ nvidia-smi
Failed to initialize NVML: Driver/library version mismatch
(stable-diffusion-webui) yeqiang@yeqiang-MS-7B23:~/Downloads/ai/stable-diffusion-webui$ cat /sys/module/nvidia/version
520.61.05
(stable-diffusion-webui) yeqiang@yeqiang-MS-7B23:~/Downloads/ai/stable-diffusion-webui$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module 520.61.05 Thu Sep 29 05:30:25 UTC 2022
GCC version: gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1)