Skip to main content
lllyasviel /

Stable Diffusion WebUI Forge

A faster, more experimental Stable Diffusion WebUI variant focused on improved resource use, quicker inference, and modern model support.

Image Generation
Versiondfdcbab
Python3.11
EnvironmentPython (uv)
InterfaceWeb UI + API
GPURequired
Securely deploy Forge on Laboratory OS.
Generate images from text prompts using the most advanced open models.

Stable Diffusion WebUI Forge

Laboratory OS Installation Details

Environment

Git Repohttps://github.com/lllyasviel/stable-diffusion-webui-forge
Working Directory/workspace/sd-webui-forge
Python3.11
Env Manageruv

Environment Variables

APP_DIRECTORY
/workspace/sd-webui-forge
PORT
<assigned at runtime>
APP_VERSIONWhich version of the app to use, using a git branch name or commit hash.
dfdcbab
INITIAL_MODELForge requires a model to already be downloaded.
https://civitai.com/api/download/models/128713?type=Model&format=SafeTensor&size=pruned&fp=fp16

Install & Run

install-and-run.sh
#!/bin/bash
set -e

export PATH="/opt/conda/bin:/root/.local/bin:$PATH"

# Clone the GitHub repository into the directory when needed
mkdir -p "/workspace/sd-webui-forge"
if [ -d "/workspace/sd-webui-forge/.git" ]; then
  echo "Git repository already initialized in /workspace/sd-webui-forge"
elif [ -z "$(ls -A "/workspace/sd-webui-forge" 2>/dev/null)" ]; then
  git clone --progress "https://github.com/lllyasviel/stable-diffusion-webui-forge" "/workspace/sd-webui-forge"
else
  echo "Working directory /workspace/sd-webui-forge already exists and is not a git repository."
  echo "Leaving existing files untouched and skipping clone of https://github.com/lllyasviel/stable-diffusion-webui-forge."
fi
  
# Change to the app directory
cd "/workspace/sd-webui-forge"

# Install the requested Python version and create a virtual environment when needed
uv python install 3.11
if [ ! -d ".venv" ]; then
  uv venv --seed --python 3.11 .venv
else
  echo "Virtual environment already exists at /workspace/sd-webui-forge/.venv"
fi

# Activate the virtual environment
source .venv/bin/activate


# Install PyTorch
uv pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu128

# Environment setup complete
echo "Environment setup complete!"

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu121
python3 -m pip install "setuptools==69.5.1"
python3 -m pip install -r "$APP_DIRECTORY/requirements_versions.txt"
python3 -m pip install "meson-python" meson ninja
python3 -m pip install joblib "bitsandbytes==0.45.3"
python3 -m pip install -r "$APP_DIRECTORY/extensions-builtin/forge_legacy_preprocessors/requirements.txt"
python3 -m pip install -r "$APP_DIRECTORY/extensions-builtin/sd_forge_controlnet/requirements.txt"
python3 -m pip install "https://github.com/huchenlei/HandRefinerPortable/releases/download/v1.0.1/handrefinerportable-2024.2.12.0-py2.py3-none-any.whl" "https://github.com/huchenlei/Depth-Anything/releases/download/v1.0.0/depth_anything-2024.1.22.0-py2.py3-none-any.whl" "https://github.com/MackinationsAi/UDAV2-ControlNet/releases/download/v1.0.0/depth_anything_v2-2024.7.1.0-py2.py3-none-any.whl"
# CLIP's legacy build breaks under isolated builds with newer setuptools/pkg_resources changes.
python3 -m pip install --no-build-isolation "https://github.com/openai/CLIP/archive/d50d76daa670286dd6cacf3bcd80b5e4823fc8e1.zip"
python3 -m pip install --force-reinstall "numpy==1.26.2" "scikit-image==0.21.0"

python3 "$APP_DIRECTORY/launch.py" --api --port "$PORT" --skip-torch-cuda-test --no-download-sd-model $OPENLAB_EXTRA_ARGS