Stable Diffusion WebUI: GPU Optimization and Settings
A practical image-generation setup covering VRAM, precision, attention backends, resolution, and safe remote access.
By Hostnot GPU ·
This guide concerns AUTOMATIC1111 Stable Diffusion WebUI, not every interface called “WebUI.” The launch options cited here are present in its v1.10.1 source. That is a reference for syntax, not a recommendation to deploy an old dependency stack on every GPU. Select and security-review a maintained revision supported by your hardware before installation.
Prepare a private environment
Use an authorized Linux GPU instance with a working driver, Git, a Python version supported by the selected WebUI revision, sufficient host RAM/disk, and a regular non-root user. Read the revision's dependency instructions; an arbitrary newer Python or torch can break its launcher. Verify the project's native CUDA test instead of bypassing it with skip flags.
Choose a trusted, licensed checkpoint compatible with that WebUI release and model family. Prefer a publisher-provided safetensors artifact, verify its hash, and retain the matching VAE/config when required. Safetensors avoids pickle deserialization of weights but does not make extensions or other downloaded Python code trustworthy. Do not enable unsafe unpickling to load an unknown file.
Pin and inspect the application
In a new project directory, obtain the official repository and check out the approved immutable commit. The clone downloads code but does not launch it. Review its launcher and dependency installation behavior before the first run.
: "${WEBUI_REVISION:?Set the approved full WebUI commit}"
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git webui-reviewed
git -C webui-reviewed checkout --detach "$WEBUI_REVISION"
git -C webui-reviewed rev-parse HEAD
Follow that revision's installation steps as the non-root user. The first webui.sh run can create its environment, install dependencies, and download supporting models. Plan for those network and storage costs; do not treat launching as a read-only operation. Keep third-party extensions disabled for the first test.
Launch on loopback and tunnel from your computer
After the reviewed environment is prepared, the following reference launch selects your already downloaded checkpoint and explicitly uses loopback. Confirm the same flags exist in your chosen revision.
: "${CHECKPOINT:?Set the full path to the reviewed safetensors checkpoint}"
./webui-reviewed/webui.sh --server-name 127.0.0.1 --port 7860 --ckpt "$CHECKPOINT" --disable-extra-extensions
From your local computer, use current assigned SSH details to forward port 7860:
: "${GPU_HOST:?Set the assigned SSH host}"
: "${GPU_PORT:?Set the assigned SSH port}"
: "${GPU_USER:?Set the assigned SSH user}"
ssh -N -o ExitOnForwardFailure=yes -o IdentitiesOnly=yes -i "$HOME/.ssh/hostnotgpu_ed25519" -p "$GPU_PORT" -L 127.0.0.1:7860:127.0.0.1:7860 "$GPU_USER@$GPU_HOST"
Open http://127.0.0.1:7860 locally after verifying the SSH fingerprint. Avoid --listen, --share, public port publishing, and insecure extension-access switches for this development setup. Loopback is not user authentication on a multi-user machine; add approved access controls if other local users are untrusted.
Establish one reproducible image
Start with batch size one, a fixed seed, the model's appropriate base resolution, a documented sampler, and a modest step count. Disable high-resolution second passes, upscalers, ControlNet, LoRAs, and optional extensions initially. Record checkpoint hash, VAE, sampler/scheduler, steps, CFG scale, seed, resolution, precision, and attention backend. Compare the saved image and generation parameters, not just whether the page loaded.
Tune only the diagnosed constraint
For CUDA OOM, first reduce resolution or batch size and disable extra passes. Supported --medvram or --medvram-sdxl modes trade transfer overhead for memory; --lowvram can be slower still. These are WebUI-specific options, not generic Diffusers flags. Test either the supported PyTorch attention path or a compatible xformers build; do not force-install an incompatible binary for a promised speedup.
Black images or NaNs warrant checking the checkpoint/VAE pairing and precision path. A targeted --no-half-vae test can help where supported, but increases memory. Skipping NaN/CUDA checks hides the symptom. For extension-only failures, reproduce with extra extensions disabled before changing the driver.
Measure warm generation time separately from startup and downloads. Increasing resolution and second passes can dominate both VRAM and rented runtime. Generated image metadata can contain private prompts: inspect it before publishing images. Back up needed outputs, stop the UI and tunnel, and terminate unused compute via instance controls. See performance diagnosis for measurement design.