{"id":17227188,"url":"https://github.com/triple-mu/hunyuandit-tensorrt-libtorch","last_synced_at":"2025-04-14T01:14:22.205Z","repository":{"id":240262234,"uuid":"802138626","full_name":"triple-Mu/HunyuanDiT-TensorRT-libtorch","owner":"triple-Mu","description":"HunyuanDiT with TensorRT and libtorch","archived":false,"fork":false,"pushed_at":"2024-05-22T14:36:07.000Z","size":28,"stargazers_count":17,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T01:14:11.986Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/triple-Mu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-17T15:36:48.000Z","updated_at":"2025-01-07T10:45:22.000Z","dependencies_parsed_at":"2024-05-17T17:04:23.923Z","dependency_job_id":null,"html_url":"https://github.com/triple-Mu/HunyuanDiT-TensorRT-libtorch","commit_stats":null,"previous_names":["triple-mu/hunyuandit-tensorrt-libtorch"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triple-Mu%2FHunyuanDiT-TensorRT-libtorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triple-Mu%2FHunyuanDiT-TensorRT-libtorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triple-Mu%2FHunyuanDiT-TensorRT-libtorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/triple-Mu%2FHunyuanDiT-TensorRT-libtorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/triple-Mu","download_url":"https://codeload.github.com/triple-Mu/HunyuanDiT-TensorRT-libtorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804826,"owners_count":21164135,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-15T04:18:27.443Z","updated_at":"2025-04-14T01:14:22.182Z","avatar_url":"https://github.com/triple-Mu.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HunyuanDiT-TensorRT-libtorch\n\n用`TensorRT`和`libtorch`简单实现了`HunyuanDiT`模型的`pipeline`推理。\n\n## 准备\n\n- 安装`TensorRT`, `TensorRT10`的api变化了, 建议用`TensorRT8`以下的版本\n- 从[huggingface](`https://huggingface.co/Tencent-Hunyuan/HunyuanDiT/tree/main`)下载模型\n- 安装`pytorch`, `onnx`等依赖\n\n## 导出4个onnx模型用于pipeline\n\n修改[export.py](export.py)中的`args`\n执行:\n\n```shell\npython export.py\n```\n\n你会得到`bert`, `t5`, `hunyuan`, `vae`四个onnx模型\n你可以用[onnxsim](`https://github.com/daquexian/onnx-simplifier`)将它们简化\n执行:\n\n```shell\nonnxsim bert.onnx bert-sim.onnx\nonnxsim t5.onnx t5-sim.onnx\nonnxsim hunyuan.onnx hunyuan-sim.onnx\nonnxsim vae.onnx vae-sim.onnx\n```\n\nonnx很大的情况下, 简化的耗时也很长\n\n## onnx转换到tensorrt\n\n这里我用了trtexec转化, 比较省事\n\n```shell\ntrtexec --onnx=bert-sim.onnx --saveEngine=bert.plan --fp16\ntrtexec --onnx=t5-sim.onnx --saveEngine=t5.plan --fp16\ntrtexec --onnx=hunyuan-sim.onnx --saveEngine=hunyuan.plan --fp16\ntrtexec --onnx=vae-sim.onnx --saveEngine=vae.plan --fp16\n```\n\ntensorrt转换的过程也很慢\n\n## 编译安装python包\n\n执行:\n\n```shell\npython setup.py install\n```\n\n包名是: `py_hunyuan_dit`\n\n## 推理一个文生图\n\n修改[run.py](run.py)中的4个模型路径, 修改推理步数, 默认100比较慢\n\n执行:\n\n```shell\npython run.py\n```\n\n你会看到生成的图片\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriple-mu%2Fhunyuandit-tensorrt-libtorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftriple-mu%2Fhunyuandit-tensorrt-libtorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriple-mu%2Fhunyuandit-tensorrt-libtorch/lists"}