> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-de/bildgenerierung/sdxl-turbo.md).

# SDXL Turbo & LCM

Erzeuge Bilder in 1–4 Schritten mit SDXL Turbo und Latent Consistency Models auf CLORE.AI-GPUs.

{% hint style="success" %}
Alle Beispiele können auf GPU-Servern ausgeführt werden, die über [CLORE.AI Marketplace](https://clore.ai/marketplace).
{% endhint %}

## Warum SDXL Turbo / LCM?

* **Echtzeit-Geschwindigkeit** - Erzeuge Bilder in 1–4 Schritten statt 30–50
* **Gleiche Qualität** - Vergleichbar mit vollem SDXL bei 10x weniger Schritten
* **Interaktiv** - Schnell genug für Echtzeitanwendungen
* **Wenig VRAM** - Effiziente Speichernutzung
* **LoRA-kompatibel** - Verwendung mit vorhandenen SDXL-LoRAs

## Modellvarianten

| Modell          | Schritte | Geschwindigkeit | Qualität      | VRAM |
| --------------- | -------- | --------------- | ------------- | ---- |
| SDXL Turbo      | 1-4      | Am schnellsten  | Gut           | 8GB  |
| SDXL Lightning  | 2-8      | Sehr schnell    | Großartig     | 8GB  |
| LCM-SDXL        | 4-8      | Schnell         | Großartig     | 8GB  |
| LCM-LoRA + SDXL | 4-8      | Schnell         | Ausgezeichnet | 10GB |
| SD Turbo (1.5)  | 1-4      | Am schnellsten  | Gut           | 4GB  |

## Schnelle Bereitstellung auf CLORE.AI

**Docker-Image:**

```
pytorch/pytorch:2.5.1-cuda12.4-cudnn9-devel
```

**Ports:**

```
22/tcp
7860/http
```

**Befehl:**

```bash
pip install diffusers transformers accelerate gradio && \
python -c "
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    'stabilityai/sdxl-turbo',
    torch_dtype=torch.float16,
    variant='fp16'
).to('cuda')

def generate(prompt, steps, seed):
    generator = torch.Generator('cuda').manual_seed(seed) if seed > 0 else None
    image = pipe(prompt, num_inference_steps=steps, guidance_scale=0.0, generator=generator).images[0]
    return image

gr.Interface(
    fn=generate,
    inputs=[
        gr.Textbox(label='Prompt'),
        gr.Slider(1, 4, value=1, step=1, label='Steps'),
        gr.Number(value=-1, label='Seed')
    ],
    outputs=gr.Image(),
    title='SDXL Turbo - Echtzeit-Generierung'
).launch(server_name='0.0.0.0', server_port=7860)
"
```

## Zugriff auf Ihren Dienst

Nach der Bereitstellung finden Sie Ihre `http_pub` URL in **Meine Bestellungen**:

1. Gehen Sie zur **Meine Bestellungen** Seite
2. Klicken Sie auf Ihre Bestellung
3. Finden Sie die `http_pub` URL (z. B., `abc123.clorecloud.net`)

Verwenden Sie `https://IHRE_HTTP_PUB_URL` anstelle von `localhost` in den Beispielen unten.

## Hardware-Anforderungen

| Modell         | Minimale GPU  | Empfohlen |
| -------------- | ------------- | --------- |
| SD Turbo       | RTX 3060 8GB  | RTX 3070  |
| SDXL Turbo     | RTX 3070 8GB  | RTX 3080  |
| SDXL Lightning | RTX 3070 8GB  | RTX 3090  |
| LCM-SDXL       | RTX 3080 10GB | RTX 4090  |

## Installation

```bash
pip install diffusers transformers accelerate torch
```

## SDXL Turbo

### Grundlegende Verwendung

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

# In 1 Schritt generieren!
image = pipe(
    prompt="Eine filmische Aufnahme eines Baby-Waschbären, der ein kunstvolles italienisches Priestergewand trägt",
    num_inference_steps=1,
    guidance_scale=0.0  # Turbo verwendet kein CFG
).images[0]

image.save("raccoon.png")
```

### Beste Einstellungen

```python
# 1 Schritt - am schnellsten, gute Qualität
image = pipe(prompt, num_inference_steps=1, guidance_scale=0.0).images[0]

# 2 Schritte - bessere Details
image = pipe(prompt, num_inference_steps=2, guidance_scale=0.0).images[0]

# 4 Schritte - beste Qualität für Turbo
image = pipe(prompt, num_inference_steps=4, guidance_scale=0.0).images[0]
```

## SDXL Lightning

### 2-Schritt-Generierung

```python
import torch
from diffusers import StableDiffusionXLPipeline, EulerDiscreteScheduler
from huggingface_hub import hf_hub_download

base = "stabilityai/stable-diffusion-xl-base-1.0"
repo = "ByteDance/SDXL-Lightning"
ckpt = "sdxl_lightning_2step_unet.safetensors"

# Basismodell laden
pipe = StableDiffusionXLPipeline.from_pretrained(
    base,
    torch_dtype=torch.float16,
    variant="fp16"
).to("cuda")

# Lightning-Unet laden
pipe.unet.load_state_dict(
    torch.load(hf_hub_download(repo, ckpt), map_location="cuda")
)

# Scheduler konfigurieren
pipe.scheduler = EulerDiscreteScheduler.from_config(
    pipe.scheduler.config,
    timestep_spacing="trailing"
)

# In 2 Schritten generieren
image = pipe(
    "Ein Mädchen, das in einem Garten lächelt",
    num_inference_steps=2,
    guidance_scale=0.0
).images[0]

image.save("lightning.png")
```

### 4-Schritte (höhere Qualität)

```python
ckpt = "sdxl_lightning_4step_unet.safetensors"
# ... gleiche Einrichtung ...

image = pipe(
    prompt,
    num_inference_steps=4,
    guidance_scale=0.0
).images[0]
```

## LCM-LoRA

Mit jedem SDXL-Modell für schnelle Generierung verwenden:

```python
import torch
from diffusers import DiffusionPipeline, LCMScheduler

pipe = DiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-xl-base-1.0",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

# LCM-LoRA laden
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")

# LCM-Scheduler setzen
pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)

# In 4 Schritten generieren
image = pipe(
    "Astronaut im Dschungel, kühle Farbpalette, gedämpfte Farben, detailliert, 8k",
    num_inference_steps=4,
    guidance_scale=1.0  # LCM verwendet niedrigen CFG
).images[0]

image.save("lcm_lora.png")
```

### Mit benutzerdefinierten LoRAs

```python
# Basis + LCM-LoRA + Style-LoRA laden
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl", adapter_name="lcm")
pipe.load_lora_weights("your-style-lora", adapter_name="style")

# Adapter kombinieren
pipe.set_adapters(["lcm", "style"], adapter_weights=[1.0, 0.8])

image = pipe(prompt, num_inference_steps=4, guidance_scale=1.5).images[0]
```

## SD Turbo (SD 1.5)

Für geringere VRAM-Anforderungen:

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sd-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

image = pipe(
    "Ein Foto einer Katze",
    num_inference_steps=1,
    guidance_scale=0.0
).images[0]
```

## Bild-zu-Bild

### SDXL Turbo Img2Img

```python
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import load_image

pipe = AutoPipelineForImage2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16,
    variant="fp16"
)
pipe.to("cuda")

init_image = load_image("input.jpg").resize((512, 512))

image = pipe(
    prompt="Katzenzauberer, Gandalf, Herr der Ringe, detailliert, Fantasy",
    image=init_image,
    num_inference_steps=2,
    strength=0.5,
    guidance_scale=0.0
).images[0]
```

## Batch-Erzeugung

```python
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16
).to("cuda")

prompts = [
    "Ein Sonnenuntergang über Bergen",
    "Eine futuristische Stadt bei Nacht",
    "Ein niedlicher Roboter in einem Garten",
    "Ein antiker Tempel im Nebel"
]

# Batch-Generierung
images = pipe(
    prompts,
    num_inference_steps=1,
    guidance_scale=0.0
).images

for i, img in enumerate(images):
    img.save(f"batch_{i}.png")
```

## Echtzeit-Streaming

```python
import gradio as gr
import torch
from diffusers import AutoPipelineForText2Image

pipe = AutoPipelineForText2Image.from_pretrained(
    "stabilityai/sdxl-turbo",
    torch_dtype=torch.float16
).to("cuda")

def generate_realtime(prompt):
    if not prompt:
        return None
    image = pipe(
        prompt,
        num_inference_steps=1,
        guidance_scale=0.0,
        width=512,
        height=512
    ).images[0]
    return image

demo = gr.Interface(
    fn=generate_realtime,
    inputs=gr.Textbox(label="Prompt"),
    outputs=gr.Image(label="Generiert"),
    live=True,  # Aktualisierung beim Tippen
    title="Echtzeit SDXL Turbo"
)

demo.launch(server_name="0.0.0.0", server_port=7860)
```

## Leistungsvergleich

| Modell         | Schritte | Auflösung | RTX 3090 | RTX 4090 | A100  |
| -------------- | -------- | --------- | -------- | -------- | ----- |
| SDXL (Basis)   | 30       | 1024x1024 | 8s       | 5s       | 4s    |
| SDXL Turbo     | 1        | 512x512   | 0.3s     | 0.2s     | 0.15s |
| SDXL Turbo     | 4        | 512x512   | 0.8s     | 0.5s     | 0.4s  |
| SDXL Lightning | 2        | 1024x1024 | 0.8s     | 0.5s     | 0.4s  |
| SDXL Lightning | 4        | 1024x1024 | 1.2s     | 0.8s     | 0.6s  |
| LCM-SDXL       | 4        | 1024x1024 | 1.5s     | 1.0s     | 0.7s  |

## Qualitätsvergleich

| Aspekt          | SDXL 30 Schritte | Turbo 4 Schritte | Lightning 4 Schritte |
| --------------- | ---------------- | ---------------- | -------------------- |
| Details         | Ausgezeichnet    | Gut              | Großartig            |
| Textdarstellung | Gut              | Schlecht         | Schlecht             |
| Gesichter       | Großartig        | Gut              | Gut                  |
| Konsistenz      | Ausgezeichnet    | Gut              | Großartig            |
| Stilvielfalt    | Ausgezeichnet    | Gut              | Großartig            |

## Wann man was verwenden sollte

| Einsatzgebiet                 | Empfohlen      | Schritte |
| ----------------------------- | -------------- | -------- |
| Echtzeitvorschau              | SDXL Turbo     | 1        |
| Interaktive Apps              | SDXL Turbo     | 1-2      |
| Schnelle Iterationen          | SDXL Lightning | 2-4      |
| Mit benutzerdefinierten LoRAs | LCM-LoRA       | 4-8      |
| Maximale Qualität             | SDXL Lightning | 8        |
| Wenig VRAM                    | SD Turbo       | 1-2      |

## Kostenabschätzung

Typische CLORE.AI-Marktplatzpreise:

| GPU           | Stundensatz | Bilder/Stunde (1-Schritt) |
| ------------- | ----------- | ------------------------- |
| RTX 3060 12GB | \~$0.03     | \~3,000                   |
| RTX 3090 24GB | \~$0.06     | \~8,000                   |
| RTX 4090 24GB | \~$0.10     | \~12,000                  |
| A100 40GB     | \~$0.17     | \~15,000                  |

*Preise variieren. Prüfe* [*CLORE.AI Marketplace*](https://clore.ai/marketplace) *auf aktuelle Preise.*

## Fehlerbehebung

### Verschwommene Ergebnisse

* SDXL Turbo gibt nativ 512x512 aus
* Verwende SDXL Lightning für 1024x1024
* Füge Upscaling als Nachbearbeitung hinzu

### guidance\_scale Fehler

```python
# SDXL Turbo: immer 0.0 verwenden
image = pipe(prompt, guidance_scale=0.0).images[0]

# LCM: 1.0–2.0 verwenden
image = pipe(prompt, guidance_scale=1.5).images[0]

# Lightning: 0.0 verwenden
image = pipe(prompt, guidance_scale=0.0).images[0]
```

### LoRA funktioniert nicht

```python
# Für LCM-LoRA muss LCMScheduler verwendet werden
from diffusers import LCMScheduler

pipe.scheduler = LCMScheduler.from_config(pipe.scheduler.config)
pipe.load_lora_weights("latent-consistency/lcm-lora-sdxl")
```

### Kein Speicher mehr

```python
# Aktiviere Speicheroptimierungen
pipe.enable_model_cpu_offload()
pipe.enable_vae_slicing()

# Oder verwende ein kleineres Modell
# SD Turbo statt SDXL Turbo
```

## Nächste Schritte

* [FLUX.1](/guides/guides_v2-de/bildgenerierung/flux.md) - Generierung mit höchster Qualität
* [Stable Diffusion WebUI](/guides/guides_v2-de/bildgenerierung/stable-diffusion-webui.md) - Vollständige UI
* [ComfyUI](/guides/guides_v2-de/bildgenerierung/comfyui.md) - Knotenbasierte Workflows
* [Real-ESRGAN](/guides/guides_v2-de/bildverarbeitung/real-esrgan-upscaling.md) - Ergebnisse hochskalieren


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-de/bildgenerierung/sdxl-turbo.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
