Stable Diffusion: Linux, Mac environment installation tutorial

1. Configure the Python environment

1. Install conda

Script acquisition link: https://repo.anaconda.com/archive/

Press Enter all the way, the input yes input yes

wget -c https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh

2. Install python3.10.9 environment

Use conda to install python3.10.9 environment

  • If you have not installed conda, install conda first, or search for Linux to install python3.10.9 for installation
conda create -n sd python=3.10.9 -c conda-forge -y

After the creation is complete, use the environment

conda activate sd

2. Install PyTorch

1. CPU version

Official website: https://pytorch.org/get-started/locally/#mac-prerequisites

Both Linux and Mac can use the following download method:

pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu

2. If there is a GPU, check the cuda version first

Execute the command nvidia-smi to check whether the cuda version in the upper right corner is greater than or equal to 11.8. If it is greater than or equal to 11.8, execute the following command to install PyTorch

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

2.1 Install NVIDIA driver

  1. Reinstall graphics driver
  2. Confirm the model of the graphics card and execute the command: lspci
  3. Enter the nvidia official website to download the corresponding driver: https://www.nvidia.cn/geforce/drivers/

Uninstall the original driver

sudo apt remove --purge "nvidia-*" -y

install driver

sudo ./NVIDIA-Linux-x86_64-530.41.03.run -no-x-check -no-nouveau-check -no-opengl-files //安装

2.3 Install CUDA

CUDA official website download address: https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=deb_network

apt-get install libnvidia-decode-530
apt-get install libnvidia-encode-530
apt-get install nvidia-driver-530

apt install nvidia-settings nvidia-prime libnvidia-compute-530:i386 libnvidia-decode-530:i386 libnvidia-encode-530:i386 libnvidia-fbc1-530:i386 libnvidia-gl-530:i386

Modify environment variables

echo 'export PATH="/usr/local/cuda-12/bin:$PATH"' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH="/usr/local/cuda-12/LIB64:$LD_LIBRARY_PATH"' >> ~/.bashrc
source ~/.bashrc
nvcc -V

2.4 Error reporting when installing NVIDIA or CUDA

一、NVIDIA driver install - Error: Unable to find the kernel source tree

Solution

sudo apt-get install linux-headers-`uname -r`

2. Error Cannot locate TCMalloc

Solution

sudo apt-get install libgoogle-perftools4 libtcmalloc-minimal4 -y

3. Install the required components in advance

Replace the Tsinghua source first, and the download will be faster (it doesn’t matter if you hang an agent)

pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Download components

pip3 install gfpgan ftfy regex tqdm
pip install git+https://github.com/openai/CLIP.git

Three, stable diffusion start

3.1 Installation

From the clone source code on GitHub, it is recommended to hang the proxy

git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

Enter the directory, start the installation and start

cd stable-diffusion-webui
./webui.sh

3.2 Start mode

MAC needs to execute the following startup commands

./webui.sh --no-half --enable-insecure-extension-access

modify port

  • Method 1: Edit webui-user.sh, the content is as follows, and then execute ./wehui.sh to start
# 绑定 0.0.0.0 端口,同时修改端口
export COMMANDLINE_ARGS="--listen --port 23105"
  • Method 2: Add parameters at startup
./webui.sh --enable-insecure-extension-access --disable-safe-npickle --listen --port 20022

4. Replace the extension URL

https://gitee.com/akegarasu/sd-webui-extensions/raw/master/index.md

5. Sinicization course

1. Installation

Extensions–>install from URL, enter the Chinese plug-in address, click install

https://github.com/dtlnor/stable-diffusion-webui-localization-zh_CN

2. Select language pack

settings–>User interface, click the refresh button, select zh_CN language pack

3. Submit settings

First click Apply settings to submit the settings, then click Reload UI to restart the interface.

6. Plug-ins

1. Multi Diffusion + Tiled VAE

A powerful plug-in that allows players with 4G and 6G low video memory to generate 2K, 4K or even 8K pictures

The principle is to split the original image into small pieces, and finally aggregate it into a large image. The larger the block, the slower it will be, but it will be more natural

https://github.com/pkuliyi2015/multidiffusion-upscaler-for-automatic1111

2. inpaint cutout

3. TILE model

7. Prompt words

1. Improve the success rate of hands

hand of guido daniele

8. Frequently asked questions

1. The problem of generating image garbled characters

Sampled using: DDIM, PLMS, UniPC

Guess you like

Origin blog.csdn.net/weixin_44839362/article/details/130681221