Mekal Z

Mekal Z

A programmer running out of the wall.
twitter

Install Stable Diffusion WebUI on Linux

A few days ago, I completely switched my workstation at home to Linux. I found that the Stable Diffusion WebUI integrated by Autumn Leaf, which I had installed on Windows before, was no longer usable. So I decided to install a set on Linux to play with. Unexpectedly, the installation on Linux was exceptionally simple, and the whole process went smoothly.

Mekal_cheap_cat_flea_treatment_0a75a13e-892a-4c77-8de0-9eb347d34133.png

Environment Preparation#

  • System
    • Pop!_OS 22.04 LTS, based on Ubuntu 22.04 distribution
  • Install CUDA

    If you are using Pop!_OS 22.04 LTS like me, you can directly use its version optimized for CUDA, so you don't need to tinker with the graphics card driver yourself.

  • Install git
  • Anaconda Environment
    • Check the latest version of Anaconda on the official website (installation package is about 800MB), and refer to the tutorial below for installation.
    • https://zhuanlan.zhihu.com/p/459607806
    • The version I installed: Anaconda3-2023.03-1-Linux-x86_64.sh
    • Record my installation process
      • Download the installation package
        wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh
        .sh
        
      • Install
        bash ./Anaconda3-2023.03-1-Linux-x86_64.sh
        
        • Agree to the user agreement as prompted
        • image_1682589080413_0.png
        • Confirm the installation path, and the default is to install it in the current user directory
        • image_1682590035325_0.png
        • Wait for the installation to complete
        • image_1682589559520_0.png
        • Then add the following line to the end of your current shell configuration file to add the path of the Conda executable to the environment variable
        export PATH=$PATH:~/anaconda3/bin
        
        • After adding it, source it. I'm using zsh
        source ~/.zshrc
        
        • Confirm the Python environment, and it is recommended to use 3.10
        $ python --version
        Python 3.10.9
        
    • Configuration for Chinese environment
      • Change Pip source (here using Alibaba Cloud source)
        pip config set global.index-url http://mirrors.aliyun.com/pypi/simple/
        pip config set global.trusted-host mirrors.aliyun.com
        

Download Stable Diffusion WebUI#

# You may need to prepare a ladder to access GitHub by yourself
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git

Run WebUI#

cd stable-diffusion-webui
./webui.sh
  • Yes, you read it right. There is no other installation process. Just run webui.sh to start it.
  • During the first startup, it will automatically download many necessary models and dependencies. All you need to do is ensure a smooth network connection. If the network is good, this process will be very smooth.
  • image_1682590818468_0.png

Configuration & Installation of Models#

  • Add the following parameters when starting
  • --listen
    • Used to make the web service listen to the 0.0.0.0 address, so that it can be accessed on other machines in the LAN. If you only access it locally, you don't need to add this parameter.
  • --enable-insecure-extension-access
    • After adding this parameter, you can install extensions in the web interface.
  • --medvram
    • If your graphics card memory is only 4G, you can add this parameter, which has a certain optimization effect.
unset all_proxy && unset no_proxy && ./webui.sh --listen --medvram --enable-insecure-extension-access
  • Install Chinese interface
    • Open the extension > available tab page
    • Check the hidden options, uncheck the localization, and then click the "Load from" button
    • In the list of loaded plugins below, find the localization plugin starting with zh_cn and click the install button on the right
    • After the installation is complete, switch to the "installed" tab page and click the "restart and reload" button
    • After the restart, refresh the page to see the Chinese interface
  • Install civitai extension
    • Can automatically download model extensions
    • The installation method is the same as installing the Chinese interface plugin mentioned above, but the difference is that you can install directly from the URL
    • https://github.com/civitai/sd_civitai_extension
  • Download ChilloutMix model
    • https://civitai.com/models/6424/chilloutmix
    • After downloading, put it in the ./models/Stable-diffusion path
    • After installation, click the refresh button on the top left corner of the webUI, and then scroll down to select the ChilloutMix model that was just installed
  • Download your favorite Lora model

Usage#

  • Set the model, write the prompt, and insert the Lora model tag as shown in the figure below.
  • The number after the colon in lora:yaeMikoRealistic_yaemikoMixed:0.7 is the weight. Generally, it is set between 0.5 and 0.8. If you use multiple Lora models, the total weight of the models should not exceed 1.
  • image_1682607463006_0.png
  • Set the parameters as shown in the figure below. It is recommended to use DPM++ SDE Karras, which can produce good results in at least 26 iterations. Of course, the more iterations, the higher the quality of the output image, but it also takes longer.
  • image_1682607736746_0.png

Reference Documents#

Possible Problems#

  • If you have set the all_proxy and no_proxy proxy configurations in the environment variables, you may encounter the following error. The solution is to unset these two environment variables before starting.
    unset all_proxy && unset no_proxy && ./webui.sh
    
    • image_1682594803647_0.png
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.