pdr209 commited on
Commit
deb2935
1 Parent(s): ef49e15

Create lcm/README

Browse files
Files changed (1) hide show
  1. lcm/README.md +79 -0
lcm/README.md ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: openrail++
3
+ base_model: stabilityai/stable-diffusion-xl-base-1.0
4
+ language:
5
+ - en
6
+ tags:
7
+ - stable-diffusion
8
+ - stable-diffusion-xl
9
+ - tensorrt
10
+ - text-to-image
11
+ ---
12
+
13
+ # Stable Diffusion XL 1.0 TensorRT
14
+
15
+ ## Introduction
16
+
17
+ This repository hosts the Latent Consistency Model(LCM) TensorRT versions of **Stable Diffusion XL 1.0** created in collaboration with [NVIDIA](https://huggingface.co/nvidia). The optimized versions give substantial improvements in speed and efficiency.
18
+
19
+ See the [usage instructions](#usage-example) for how to run the SDXL pipeline with the ONNX files hosted in this repository. The first invocation produces plan files in `engine_xl_base` and `engine_xl_refiner` specific to the accelerator being run on and are reused for later invocations.
20
+
21
+ ## Model Description
22
+
23
+ - **Developed by:** Stability AI
24
+ - **Model type:** Diffusion-based text-to-image generative model
25
+ - **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0/blob/main/LICENSE.md)
26
+ - **Model Description:** This is a Latent Consistency Model (LCM) version of the [SDXL base 1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0) and [SDXL refiner 1.0](https://huggingface.co/stabilityai/stable-diffusion-xl-refiner-1.0) models for [NVIDIA TensorRT](https://developer.nvidia.com/tensorrt) optimized inference
27
+
28
+
29
+ ## Performance Comparison
30
+
31
+ #### Timings for 4 steps at 1024x1024
32
+
33
+ | Accelerator | CLIP | Unet | VAE |Total |
34
+ |-------------|--------------------------|-----------------------------|------------------------|------------------------|
35
+ | A100 | 1.08 ms | 192.02 ms | 228.34 ms | 426.16 ms |
36
+ | H100 | 0.77 ms | 129.09 ms | 127.44 ms | 261.15 ms |
37
+
38
+
39
+
40
+ ## Usage Example
41
+
42
+ 1. Following the [setup instructions](https://github.com/rajeevsrao/TensorRT/blob/release/8.6/demo/Diffusion/README.md) on launching a TensorRT NGC container.
43
+ ```shell
44
+ git clone https://github.com/rajeevsrao/TensorRT.git
45
+ cd TensorRT
46
+ git checkout release/9.2
47
+ docker run --rm -it --gpus all -v $PWD:/workspace nvcr.io/nvidia/pytorch:23.11-py3 /bin/bash
48
+ ```
49
+
50
+ 2. Download the SDXL LCM TensorRT files from this repo
51
+ ```shell
52
+ git lfs install
53
+ git clone https://huggingface.co/stabilityai/stable-diffusion-xl-1.0-tensorrt
54
+ cd stable-diffusion-xl-1.0-tensorrt
55
+ git lfs pull
56
+ cd ..
57
+ ```
58
+
59
+ 3. Install libraries and requirements
60
+ ```shell
61
+ cd demo/Diffusion
62
+ python3 -m pip install --upgrade pip
63
+ pip3 install -r requirements.txt
64
+ python3 -m pip install --pre --upgrade --extra-index-url https://pypi.nvidia.com tensorrt
65
+ ```
66
+
67
+ 4. Perform TensorRT optimized inference
68
+ ```
69
+ python3 demo_txt2img_xl.py \
70
+ ""Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"" \
71
+ --version=xl-1.0 \
72
+ --onnx-dir /workspace/stable-diffusion-xl-1.0-tensorrt/lcm \
73
+ --engine-dir /workspace/stable-diffusion-xl-1.0-tensorrt/engine-sdxl-lcm-nocfg \
74
+ --scheduler LCM \
75
+ --denoising-steps 4 \
76
+ --guidance-scale 0.0 \
77
+ --seed 42
78
+
79
+ ```