Skip to content

Offline Image Generation

SDXL (Local) Image Generation — Setup Guide

Overview

SDXL (Stable Diffusion XL) enables local GPU-based image generation without API keys or cloud costs. Requires an NVIDIA GPU with a minimum of 12 GB VRAM (16 GB recommended).

Requirements:

  • NVIDIA GPU (RTX 3060 12 GB or better; RTX 4000/5000 series ideal)
  • ~13 GB disk space for model cache
  • Windows 10/11
  • Vizard 8

Step 1 — Install PyTorch with CUDA Support

Open Command Prompt as Administrator (right-click → Run as administrator). Administrator access ensures packages install into Vizard's site-packages.

For RTX 5080/5090 (Blackwell — compute capability 12.0), these GPUs need PyTorch nightly with CUDA 12.8 support:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -m pip install -U --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu128

For RTX 3000/4000 series (Ampere/Ada — compute capability 8.x/8.9), stable PyTorch with CUDA 12.6 works fine:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -m pip install -U torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126

Verify torch sees your GPU:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "import torch; print(torch.__version__); print(torch.cuda.is_available()); print(torch.cuda.get_device_name(0))"

Expected output example:

2.12.0.dev20260329+cu128
True
NVIDIA GeForce RTX 5080

If torch.cuda.is_available() prints False, the installation failed.

Step 2 — Install Diffusers and Other Dependencies

From the admin command prompt:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -m pip install diffusers transformers accelerate safetensors invisible-watermark pillow huggingface_hub

Step 3 — Log In to Hugging Face

The SDXL model is hosted on Hugging Face and requires authentication.

  1. Create a Hugging Face account — visit huggingface.co/join and sign up (free).
  2. Create an access token — go to huggingface.co/settings/tokens, click New token, name it (e.g. "vizard"), select Read access, and click Generate. Copy the token (starts with hf_).
  3. Log in via Python — replace YOUR_TOKEN_HERE with your actual token:
"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "from huggingface_hub import login; login(token='YOUR_TOKEN_HERE')"

No output indicates success. The token saves to C:\Users\YOUR_USERNAME\.cache\huggingface\token.

Security note

Never share your token in chat, email, or version control. If exposed, immediately revoke it at the settings URL and create a new one.

Step 4 — Download the SDXL Model

Download size: ~7 GB; disk space required: ~13 GB.

From the admin command prompt:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "from diffusers import StableDiffusionXLPipeline; StableDiffusionXLPipeline.from_pretrained('stabilityai/stable-diffusion-xl-base-1.0', use_safetensors=True)"

Download displays progress bars and takes 10–20 minutes depending on connection speed.

If download fails with WinError 10054 or WinError 10038, use single-threaded download instead:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "from huggingface_hub import snapshot_download; snapshot_download('stabilityai/stable-diffusion-xl-base-1.0', max_workers=1)"

This avoids a known Windows bug where parallel downloads corrupt the connection pool. It's slower but reliable.

If single-threaded download also fails, use the retry script included in the E-Learning Lab folder (download_sdxl.py). Run it from the E-Learning Lab directory:

cd "D:\SightLab_Assembla\Demos\Lasell Templates\E-Learning Lab"
"C:\Program Files\WorldViz\Vizard8\bin\python.exe" download_sdxl.py

This script calls snapshot_download in a loop with up to 20 retries. Already-downloaded files are skipped automatically, so each retry resumes from the previous stopping point.

Files cache at:

C:\Users\YOUR_USERNAME\.cache\huggingface\hub\models--stabilityai--stable-diffusion-xl-base-1.0

Symlinks warning: This is harmless — it means the cache uses more disk space (~13 GB instead of ~7 GB). To fix it, enable Windows Developer Mode: Settings > System > For developers > Developer Mode > On.

To download a different model:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "from diffusers import StableDiffusionXLPipeline; StableDiffusionXLPipeline.from_pretrained('SG161222/RealVisXL_V5.0', use_safetensors=True)"

Note: different models may require pipeline differences.

Step 5 — Configure the E-Learning Lab

Open AI_Enabled/AI_Agent/configs/AI_Agent_Config_Education.py. The SDXL settings are already present. Key configuration options:

# To use SDXL as default, change this:
IMAGE_PROVIDER = 'SDXL (Local)'

# Model and quality settings:
SDXL_MODEL_ID = 'stabilityai/stable-diffusion-xl-base-1.0'
SDXL_STEPS = 30              # Higher = better quality, slower (20-50)
SDXL_GUIDANCE_SCALE = 5.0    # How closely to follow prompt (3.0-9.0)
SDXL_WIDTH = 1024            # Best at 1024x1024
SDXL_HEIGHT = 1024

Alternatively, select SDXL (Local) from the dropdown in the app UI — no configuration file editing needed.

Step 6 — Test

  1. Launch the E-Learning Lab.
  2. In the Presentation Wizard or Asset Browser, look for SDXL (Local) in the Image Provider dropdown.
  3. Enter a prompt and generate an image.
  4. First generation loads the model into GPU memory (~10–15 seconds).
  5. Subsequent generations are faster (~5–15 seconds depending on steps).

Troubleshooting

"SDXL (Local)" does not appear in the dropdown — The dependencies are not installed in Vizard's Python. Re-run Step 1 and Step 2 from an admin command prompt. Verify with:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -c "import torch; import diffusers; print('OK')"

"CUDA error: no kernel image is available for execution on the device" — Your PyTorch version doesn't support your GPU. RTX 5080/5090 need the nightly build with cu128. See Step 1.

"OutOfMemoryError: CUDA out of memory" — Your GPU lacks sufficient VRAM. Try reducing resolution:

SDXL_WIDTH = 768
SDXL_HEIGHT = 768

Or reduce steps:

SDXL_STEPS = 20

"Defaulting to user installation because normal site-packages is not writeable" — You are NOT running as admin. Close the command prompt, right-click Command Prompt, select Run as administrator, and try again.

Slow first generation — This is normal. The model loads into GPU memory on first use (~10–15 seconds). Subsequent generations reuse the loaded model.

"WinError 10054" / "WinError 10038" during download — This is a known bug in the httpx library on Windows. When Hugging Face downloads multiple files in parallel, the connection pool can become corrupted, causing "connection forcibly closed" and "not a socket" errors.

Fix: use snapshot_download with max_workers=1 to force sequential downloads (see Step 4 above). Once the files are cached, from_pretrained will load them without re-downloading. If even single-threaded downloads fail, use download_sdxl.py (see Step 4) — it retries automatically and resumes from where it left off.

"Error no file named model.safetensors found in directory" — The model cache is incomplete; a previous download was interrupted. Delete the partial cache and re-download:

rmdir /s /q "%USERPROFILE%\.cache\huggingface\hub\models--stabilityai--stable-diffusion-xl-base-1.0"

Then re-run the download command from Step 4 (use max_workers=1 or download_sdxl.py to avoid the same failure).

Symlinks warning — Harmless. Enable Developer Mode to fix it: Settings > System > For developers > Developer Mode > On.

Uninstall / Disable

To disable SDXL without uninstalling, select a different provider (Gemini, OpenAI, etc.) in the config or the UI dropdown. The SDXL code is fully guarded — if the dependencies aren't loaded, nothing changes.

To remove the model cache and free ~13 GB:

rmdir /s /q "%USERPROFILE%\.cache\huggingface\hub\models--stabilityai--stable-diffusion-xl-base-1.0"

To uninstall the Python packages:

"C:\Program Files\WorldViz\Vizard8\bin\python.exe" -m pip uninstall torch torchvision torchaudio diffusers transformers accelerate safetensors invisible-watermark

Other features in the E-Learning Lab may depend on torch. Only uninstall if you're certain nothing else requires it.