English
Zhiminli commited on
Commit
460c690
·
verified ·
1 Parent(s): ef174fa

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +109 -109
README.md CHANGED
@@ -1,109 +1,109 @@
1
- ---
2
- license: other
3
- license_name: tencent-hunyuan-community
4
- license_link: https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/blob/main/LICENSE.txt
5
- language:
6
- - en
7
- ---
8
-
9
- # HunyuanDiT TensorRT Acceleration
10
-
11
- Language: **English** | [**中文**](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs/blob/main/README_zh.md)
12
-
13
- We provide a TensorRT version of [HunyuanDiT](https://github.com/Tencent/HunyuanDiT) for inference acceleration
14
- (faster than flash attention). One can convert the torch model to TensorRT model using the following steps based on
15
- **TensorRT-9.2.0.5** and **cuda (11.7 or 11.8)**.
16
-
17
- > ⚠️ Important Reminder (Suggestion for testing the TensorRT acceleration version):
18
- > We recommend users to test the TensorRT version on NVIDIA GPUs with Compute Capability >= 8.0,(For example, RTX4090,
19
- > RTX3090, H800, A10/A100/A800, etc.) you can query the Compute Capability corresponding to your GPU from
20
- > [here](https://developer.nvidia.com/cuda-gpus#compute). For NVIDIA GPUs with Compute Capability < 8.0, if you want to
21
- > try the TensorRT version, you may encounter errors that the TensorRT Engine file cannot be generated or the inference
22
- > performance is poor, the main reason is that TensorRT does not support fused mha kernel on this architecture.
23
-
24
- ## 🛠 Instructions
25
-
26
- ### 1. Download dependencies from huggingface.
27
-
28
- ```shell
29
- cd HunyuanDiT
30
- # Use the huggingface-cli tool to download the model.
31
- huggingface-cli download Tencent-Hunyuan/TensorRT-libs --local-dir ./ckpts/t2i/model_trt
32
- ```
33
-
34
- ### 2. Install the TensorRT dependencies.
35
-
36
- ```shell
37
- # Extract and install the TensorRT dependencies.
38
- sh trt/install.sh
39
-
40
- # Set the TensorRT build environment variables. We provide a script to set up the environment.
41
- source trt/activate.sh
42
- ```
43
-
44
- ### 3. Build the TensorRT engine.
45
-
46
-
47
- #### Method 1: Use the prebuilt engine
48
-
49
- We provide some prebuilt [TensorRT Engines](https://huggingface.co/Tencent-Hunyuan/TensorRT-engine), which need to be downloaded from Huggingface.
50
-
51
- | Supported GPU | Remote Path |
52
- |:----------------:|:---------------------------------:|
53
- | GeForce RTX 3090 | `engines/RTX3090/model_onnx.plan` |
54
- | GeForce RTX 4090 | `engines/RTX4090/model_onnx.plan` |
55
- | A100 | `engines/A100/model_onnx.plan` |
56
-
57
- Use the following command to download and place the engine in the specified location.
58
-
59
- *Note: Please replace `<Remote Path>` with the corresponding remote path in the table above.*
60
-
61
- ```shell
62
- export REMOTE_PATH=<Remote Path>
63
- huggingface-cli download Tencent-Hunyuan/TensorRT-engine ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/
64
- ln -s ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/model_onnx.plan
65
- ```
66
-
67
- #### Method 2: Build your own engine
68
-
69
- If you are using a different GPU, you can build the engine using the following command.
70
-
71
- ```shell
72
- # Build the TensorRT engine. By default, it will read the `ckpts` folder in the current directory.
73
- sh trt/build_engine.sh
74
- ```
75
-
76
- Finally, if you see the output like `&&&& PASSED TensorRT.trtexec [TensorRT v9200]`, the engine is built successfully.
77
-
78
- ### 4. Run the inference using the TensorRT model.
79
-
80
- ```shell
81
- # Important: If you have not activated the environment, please run the following command.
82
- source trt/activate.sh
83
-
84
- # Run the inference using the prompt-enhanced model + HunyuanDiT TensorRT model.
85
- python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt
86
-
87
- # Close prompt enhancement. (save GPU memory)
88
- python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt --no-enhance
89
- ```
90
-
91
- ### 5. Notice
92
-
93
- The TensorRT engine is designed to support following shapes of input for performance reasons.
94
- In the future, we will verify and try to support arbitrary shapes.
95
-
96
- ```python
97
- STANDARD_SHAPE = [
98
- [(768, 768), (1024, 1024), (1280, 1280)], # 1:1
99
- [(1024, 768), (1152, 864), (1280, 960)], # 4:3
100
- [(768, 1024), (864, 1152), (960, 1280)], # 3:4
101
- [(1280, 768)], # 16:9
102
- [(768, 1280)], # 9:16
103
- ]
104
- ```
105
-
106
- ## ❓ Q&A
107
-
108
- Please refer to the [Q&A](./QA.md) for more questions and answers about building the TensorRT Engine.
109
-
 
1
+ ---
2
+ license: other
3
+ license_name: tencent-hunyuan-community
4
+ license_link: https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/blob/main/LICENSE.txt
5
+ language:
6
+ - en
7
+ ---
8
+
9
+ # HunyuanDiT TensorRT Acceleration
10
+
11
+ Language: **English** | [**中文**](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs/blob/main/README_zh.md)
12
+
13
+ We provide a TensorRT version of [HunyuanDiT](https://github.com/Tencent/HunyuanDiT) for inference acceleration
14
+ (faster than flash attention). One can convert the torch model to TensorRT model using the following steps based on
15
+ **TensorRT-9.2.0.5** and **cuda (11.7 or 11.8)**.
16
+
17
+ > ⚠️ Important Reminder (Suggestion for testing the TensorRT acceleration version):
18
+ > We recommend users to test the TensorRT version on NVIDIA GPUs with Compute Capability >= 8.0,(For example, RTX4090,
19
+ > RTX3090, H800, A10/A100/A800, etc.) you can query the Compute Capability corresponding to your GPU from
20
+ > [here](https://developer.nvidia.com/cuda-gpus#compute). For NVIDIA GPUs with Compute Capability < 8.0, if you want to
21
+ > try the TensorRT version, you may encounter errors that the TensorRT Engine file cannot be generated or the inference
22
+ > performance is poor, the main reason is that TensorRT does not support fused mha kernel on this architecture.
23
+
24
+ ## 🛠 Instructions
25
+
26
+ ### 1. Download dependencies from huggingface.
27
+
28
+ ```shell
29
+ cd HunyuanDiT
30
+ # Use the huggingface-cli tool to download the model.
31
+ huggingface-cli download Tencent-Hunyuan/TensorRT-libs --local-dir ./ckpts/t2i/model_trt
32
+ ```
33
+
34
+ ### 2. Install the TensorRT dependencies.
35
+
36
+ ```shell
37
+ # Extract and install the TensorRT dependencies.
38
+ sh trt/install.sh
39
+
40
+ # Set the TensorRT build environment variables. We provide a script to set up the environment.
41
+ source trt/activate.sh
42
+ ```
43
+
44
+ ### 3. Build the TensorRT engine.
45
+
46
+
47
+ #### Method 1: Use the prebuilt engine
48
+
49
+ We provide some prebuilt [TensorRT Engines](https://huggingface.co/Tencent-Hunyuan/TensorRT-engine), which need to be downloaded from Huggingface.
50
+
51
+ | Supported GPU | Remote Path |
52
+ |:----------------:|:---------------------------------:|
53
+ | GeForce RTX 3090 | `engines/RTX3090/model_onnx.plan` |
54
+ | GeForce RTX 4090 | `engines/RTX4090/model_onnx.plan` |
55
+ | A100 | `engines/A100/model_onnx.plan` |
56
+
57
+ Use the following command to download and place the engine in the specified location.
58
+
59
+ *Note: Please replace `<Remote Path>` with the corresponding remote path in the table above.*
60
+
61
+ ```shell
62
+ export REMOTE_PATH=<Remote Path>
63
+ huggingface-cli download Tencent-Hunyuan/TensorRT-engine ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/
64
+ ln -s ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/model_onnx.plan
65
+ ```
66
+
67
+ #### Method 2: Build your own engine
68
+
69
+ If you are using a different GPU, you can build the engine using the following command.
70
+
71
+ ```shell
72
+ # Build the TensorRT engine. By default, it will read the `ckpts` folder in the current directory.
73
+ sh trt/build_engine.sh
74
+ ```
75
+
76
+ Finally, if you see the output like `&&&& PASSED TensorRT.trtexec [TensorRT v9200]`, the engine is built successfully.
77
+
78
+ ### 4. Run the inference using the TensorRT model.
79
+
80
+ ```shell
81
+ # Important: If you have not activated the environment, please run the following command.
82
+ source trt/activate.sh
83
+
84
+ # Run the inference using the prompt-enhanced model + HunyuanDiT TensorRT model.
85
+ python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt
86
+
87
+ # Close prompt enhancement. (save GPU memory)
88
+ python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt --no-enhance
89
+ ```
90
+
91
+ ### 5. Notice
92
+
93
+ The TensorRT engine is designed to support following shapes of input for performance reasons.
94
+ In the future, we will verify and try to support arbitrary shapes.
95
+
96
+ ```python
97
+ STANDARD_SHAPE = [
98
+ [(1024, 1024), (1280, 1280)], # 1:1
99
+ [(1024, 768), (1152, 864), (1280, 960)], # 4:3
100
+ [(768, 1024), (864, 1152), (960, 1280)], # 3:4
101
+ [(1280, 768)], # 16:9
102
+ [(768, 1280)], # 9:16
103
+ ]
104
+ ```
105
+
106
+ ## ❓ Q&A
107
+
108
+ Please refer to the [Q&A](./QA.md) for more questions and answers about building the TensorRT Engine.
109
+