> 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-zh/tu-xiang-sheng-cheng/flux2-klein.md).

# FLUX.2 Klein

FLUX.2 Klein——在 Clore.ai GPU 上实现亚秒级图像生成

Black Forest Labs 的 FLUX.2 Klein 是 FLUX.1 的继任者，提供相同的图像质量，但 **速度快 20–60 倍**。而 FLUX.1 每张图像需要 10–30 秒，FLUX.2 Klein 生成仅需 **不到 0.5 秒** 在 RTX 4090 上。它是一个 320 亿参数的扩散变换器（DiT）模型，采用 Apache 2.0 许可证，截至 2026 年 1 月，甚至已在 Ollama 中获得实验性支持。

## 主要特性

* **< 0.5 秒生成**：比 FLUX.1 快 20–60 倍
* **320 亿参数 DiT 架构**：与 FLUX.1 dev 质量相同
* **Apache 2.0 许可证**：可完全商用
* **支持 Ollama**：通过 Ollama 进行实验性图像生成（2026 年 1 月）
* **兼容 ComfyUI**：可直接替换 FLUX.1 工作流
* **LoRA + ControlNet**：提供社区适配器

## 需求

| 组件   | 最低            | 推荐            |
| ---- | ------------- | ------------- |
| GPU  | RTX 3090 24GB | RTX 4090 24GB |
| 显存   | 16GB（带卸载）     | 24GB          |
| 内存   | 32GB          | 64GB          |
| 磁盘   | 40GB          | 60GB          |
| CUDA | 12.8+         | 12.8+         |

**推荐的 Clore.ai GPU**：RTX 4090 24GB（$0.14–0.42/小时）— 亚秒级生成

### 速度对比：FLUX.1 vs FLUX.2 Klein

| GPU      | FLUX.1 dev（20 步） | FLUX.2 Klein | 加速倍数 |
| -------- | ---------------- | ------------ | ---- |
| RTX 3090 | 约 25 秒           | \~1.2 秒      | 20×  |
| RTX 4090 | \~12 秒           | \~0.4 秒      | 30×  |
| RTX 5090 | \~8 秒            | \~0.25 秒     | 32×  |
| H100     | \~5 秒            | \~0.15 秒     | 33×  |

## 使用 diffusers 快速开始

```python
import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein",
    torch_dtype=torch.bfloat16
)
pipe.to("cuda")

# 在 < 0.5 秒内生成图像！
image = pipe(
    prompt="一个赛博朋克 GPU 挖矿设备，位于霓虹灯照明的服务器机房中，照片级真实",
    height=1024,
    width=1024,
    num_inference_steps=4,  # Klein 只需要 4 步！
    guidance_scale=3.5,
).images[0]

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

### 内存高效模式（16GB GPU）

```python
pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein",
    torch_dtype=torch.bfloat16
)
pipe.enable_model_cpu_offload()  # 可适配 16GB
pipe.vae.enable_tiling()         # 节省约 2GB

image = pipe("一幅日落时分的山景", num_inference_steps=4).images[0]
```

## ComfyUI 工作流

FLUX.2 Klein 可在现有的 FLUX.1 ComfyUI 工作流中直接替换使用：

1. 将 FLUX.2 Klein 检查点下载到 `ComfyUI/models/diffusion_models/`
2. 在你的工作流中，将检查点节点指向 FLUX.2 Klein
3. 将步数降至 4（而不是 FLUX.1 的 20–50 步）
4. 将引导比例设置为 3.0–4.0

```bash
# 为 ComfyUI 下载模型
cd ComfyUI/models/diffusion_models/
wget https://huggingface.co/black-forest-labs/FLUX.2-klein/resolve/main/flux2-klein.safetensors
```

## 批量生成

借助亚秒级生成，FLUX.2 Klein 可实现大规模批量处理：

```python
import torch
from diffusers import FluxPipeline

pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein", torch_dtype=torch.bfloat16
).to("cuda")

prompts = [
    "一辆红色跑车行驶在山路上，电影感",
    "一家舒适的咖啡店内景，温暖灯光",
    "一名宇航员漂浮在地球上方，超写实",
    "一座秋天中的中世纪城堡，奇幻艺术",
    # ……再添加数百个
]

for i, prompt in enumerate(prompts):
    image = pipe(prompt, num_inference_steps=4, guidance_scale=3.5).images[0]
    image.save(f"batch_{i:04d}.png")
    print(f"已生成 {i+1}/{len(prompts)}")

# 在 RTX 4090 上：1 分钟内约可生成 100 张图像！
```

## LoRA 支持

```python
pipe = FluxPipeline.from_pretrained(
    "black-forest-labs/FLUX.2-klein", torch_dtype=torch.bfloat16
).to("cuda")

# 加载一个在 FLUX 架构上训练的 LoRA
pipe.load_lora_weights("your-lora/flux2-style-lora", weight_name="lora.safetensors")
pipe.fuse_lora(lora_scale=0.8)

image = pipe("一张采用训练风格的肖像", num_inference_steps=4).images[0]
```

## 给 Clore.ai 用户的建议

* **批量处理之王**：以每张 0.4 秒的速度，你可以在 RTX 4090 上每小时生成 10,000+ 张图像
* **只需 4 步**：不要使用更多——Klein 针对 4 步进行了优化（更多步骤不会提升质量）
* **与 FLUX.1 相同的 LoRA**：大多数 FLUX.1 LoRA 都与 Klein 兼容
* **ComfyUI 直接替换**：只需替换检查点，将步数改为 4
* **RTX 3090 也可用**：每张 1.2 秒在 $0.07–0.21/小时 的成本下仍然很棒

## 故障排查

| 问题            | 解决方案                                                           |
| ------------- | -------------------------------------------------------------- |
| 24GB 显存 OOM   | 使用 `enable_model_cpu_offload()` + `vae.enable_tiling()`        |
| 模糊的图像         | 确保 `num_inference_steps=4`，不要更少。检查 guidance\_scale 是否为 3.0–4.0 |
| 首次生成较慢        | 正常——模型会在首次调用时加载（约 30 秒）。后续：亚秒级                                 |
| ComfyUI 检查点错误 | 确保你拥有 `.safetensors` 文件，而不是 diffusers 格式                       |

## 延伸阅读

* [FLUX.1 指南](/guides/guides_v2-zh/tu-xiang-sheng-cheng/flux.md) — 原始 FLUX 指南，包含 LoRA 和 ControlNet 细节
* [ComfyUI 指南](/guides/guides_v2-zh/tu-xiang-sheng-cheng/comfyui.md) — ComfyUI 设置和工作流
* [Black Forest Labs 博客](https://blackforestlabs.ai/)
* [HuggingFace 模型](https://huggingface.co/black-forest-labs/FLUX.2-klein)


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/tu-xiang-sheng-cheng/flux2-klein.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
