Upload ./README_zh.md with huggingface_hub
Browse files12345678910112 unmodified lines1415161718192021222324252627289 unmodified lines3839404142434445464748495051525354555657582 unmodified lines616263# 混元-DiT TensorRT 加速[English](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs/blob/main/README.md) | 中文我们提供了将 [混元-DiT](https://github.com/Tencent/HunyuanDiT) 中的文生图模型转换为 TensorRT 的代码和相关依赖用于推理加速(比 Flash Attention 更快)。 您可以使用以下步骤使用我们 TensorRT 模型。## 1. 从 Huggingface 下载 TensorRT 的依赖文件```shellcd HunyuanDiT2 unmodified lineshuggingface-cli download Tencent-Hunyuan/TensorRT-libs --local-dir ./ckpts/t2i/model_trt```## 2. 安装 TensorRT 依赖```shellsh trt/install.sh```## 3. 构建 TensorRT engine### 方法1: 使用预构建的 engine本仓库提供了一些预构建的 TensorRT engine.9 unmodified lineshuggingface-cli download Tencent-Hunyuan/TensorRT-engine <远程地址> --local-dir ./ckpts/t2i/model_trt/engine```### 方法2: 自行构建 engine如果您使用不同于上面表格中的 GPU, 可以使用以下命令构建适配于当前 GPU 的 engine.```shell# 首先设置 TensorRT 构建相关的环境变量,我们提供了一个脚本来一键设置source trt/activate.sh# 方式1: 构建 TensorRT engine. 默认会读取当前目录下的 ckpts 文件夹sh trt/build_engine.sh# 方式2: 如果您的模型目录不是 ckpts, 需要指定模型目录sh trt/build_engine.sh </path/to/ckpts>```4. 使用 TensorRT 模型进行推理.```shell# 使用 prompt 强化 + 文生图 TensorRT 模型进行推理2 unmodified lines# 关闭 prompt 强化 (可以在显存不足时使用)python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt --no-enhance```123456789101112131415161718192 unmodified lines2223242526272829303132333435369 unmodified lines4647484950515253545556575859606162632 unmodified lines66676869707172# 混元-DiT TensorRT 加速语言: [**English**](https://huggingface.co/Tencent-Hunyuan/TensorRT-libs/blob/main/README.md) | **中文**我们提供了将 [混元-DiT](https://github.com/Tencent/HunyuanDiT) 中的文生图模型转换为 TensorRT 的代码和相关依赖用于推理加速(比 Flash Attention 更快). 您可以使用以下步骤使用我们 TensorRT 模型, 基于 **TensorRT-9.2.0.5** 和 **cuda (11.7 或 11.8)**.> ⚠️ **重要提醒 (关于TensorRT加速版本测试的建议)**:> 我们建议用户在 Compute Capability>=8.0 的 NVIDIA 显卡上测试 TensorRT 版本, (例如, RTX4090, RTX3090, H800, A10/A100/A800 等)> 您可以从[这里](https://developer.nvidia.com/cuda-gpus#compute)查询到您显卡对应的 Compute Capability。> 对于 Compute Capability<8.0 的 NVIDIA 显卡,如果您要尝试 TensorRT 版本,有可能遭遇 TensorRT Engine 文件无法生成的错误或推理性能较差> 的问题,主要原因在于 TensorRT 没有在该架构上支持 fused mha kernel。## 🛠 构建步骤### 1. 从 Huggingface 下载 TensorRT 的依赖文件```shellcd HunyuanDiT2 unmodified lineshuggingface-cli download Tencent-Hunyuan/TensorRT-libs --local-dir ./ckpts/t2i/model_trt```### 2. 安装 TensorRT 依赖```shellsh trt/install.sh```### 3. 构建 TensorRT engine#### 方法1: 使用预构建的 engine本仓库提供了一些预构建的 TensorRT engine.9 unmodified lineshuggingface-cli download Tencent-Hunyuan/TensorRT-engine <远程地址> --local-dir ./ckpts/t2i/model_trt/engine```#### 方法2: 自行构建 engine如果您使用不同于上面表格中的 GPU, 可以使用以下命令构建适配于当前 GPU 的 engine.```shell# 首先设置 TensorRT 构建相关的环境变量,我们提供了一个脚本来一键设置source trt/activate.sh# 构建 TensorRT engine. 默认会读取当前目录下的 ckpts 文件夹sh trt/build_engine.sh```### 4. 使用 TensorRT 模型进行推理.```shell# 使用 prompt 强化 + 文生图 TensorRT 模型进行推理2 unmodified lines# 关闭 prompt 强化 (可以在显存不足时使用)python sample_t2i.py --prompt "渔舟唱晚" --infer-mode trt --no-enhance```## ❓ Q&A参考 [Q&A](./QA.md) 获取更多关于构建 TensorRT Engine 的问题解答.
README_zh.md+21-12