⚠️ Important Reminder (Suggestion for testing the TensorRT acceleration version):
We recommend users to test the TensorRT version on NVIDIA GPUs with Compute Capability >= 8.0,(For example, RTX4090, RTX3090, H800, A10/A100/A800, etc.) you can query the Compute Capability corresponding to your GPU from here. For NVIDIA GPUs with Compute Capability < 8.0, if you want to try the TensorRT version, you may encounter errors that the TensorRT Engine file cannot be generated or the inference performance is poor, the main reason is that TensorRT does not support fused mha kernel on this architecture.
1cd HunyuanDiT
2# Use the huggingface-cli tool to download the model.
3huggingface-cli download Tencent-Hunyuan/TensorRT-libs --local-dir ./ckpts/t2i/model_trt1# Extract and install the TensorRT dependencies.
2sh trt/install.sh
3
4# Set the TensorRT build environment variables. We provide a script to set up the environment.
5source trt/activate.sh1# Build the TensorRT engine. By default, it will read the `ckpts` folder in the current directory.
2sh trt/build_engine.sh1# v1.1
2sh trt/build_engine.sh 1.1
3# v1.0
4sh trt/build_engine.sh 1.0&&&& PASSED TensorRT.trtexec [TensorRT v10100], the engine is built successfully.| Supported GPU | Remote Path |
|---|---|
| GeForce RTX 3090 | engines/RTX3090/model_onnx.plan |
| GeForce RTX 4090 | engines/RTX4090/model_onnx.plan |
| A100 | engines/A100/model_onnx.plan |
<Remote Path> with the corresponding remote path in the table above.1export REMOTE_PATH=<Remote Path>
2huggingface-cli download Tencent-Hunyuan/TensorRT-engine ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/
3ln -s ${REMOTE_PATH} ./ckpts/t2i/model_trt/engine/model_onnx.plan1# Important: If you have not activated the environment, please run the following command.
2source trt/activate.sh
3
4# Run the inference using the prompt-enhanced model + HunyuanDiT TensorRT model.
5python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt
6
7# Close prompt enhancement. (save GPU memory)
8python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt --no-enhance1STANDARD_SHAPE = [
2 [(1024, 1024), (1280, 1280)], # 1:1
3 [(1280, 960)], # 4:3
4 [(960, 1280)], # 3:4
5 [(1280, 768)], # 16:9
6 [(768, 1280)], # 9:16
7]