Build TensorRT Engine
Minutes of waiting, then 2–2.7× forever
- onnx_model
- trt_model
This is the last node before the fast lane, and it's the one that makes you wait. It takes the explicit ONNX graph, compiles it into a TensorRT engine tuned for your GPU, writes a .trt file next to the source, and returns an engine handle you can run now without refreshing anything. The compile is minutes on the first attempt. After that, it's a file you load in two seconds.
How much does it actually buy you
On the pack's own RTX 5070 Ti numbers at 784×1176 FP16: Small 7.5 ms, Base 16.5 ms, Large 47.3 ms, against 20.5 / 37.4 / 93.5 ms for fused ONNX. That's the 2–2.7×, and against PyTorch it's more like 4× for Small. On a single still image this is a rounding error in your workflow. On a 300-frame video pass or a batch of a thousand renders it's the difference between a coffee break and an afternoon - which is the only honest reason to be here.
Inputs
One handle plus six integers. onnx_model is the DEPTHACCEL_ONNX_MODEL you exported - and it has to be the explicit graph, not the fused one. Feed it a _fused.onnx and it errors immediately, because the fused attention ops are ORT-specific and the TensorRT parser can't read them. That error is a feature; the alternative is a confusing parse failure twenty seconds later.
Then Min H / Min W, Opt H / Opt W, Max H / Max W - the optimization profile, in 14-pixel steps, defaulting to 14×14, 1022×1022, and 2016×2016. Max H/Max W is your ceiling: the largest input the engine will accept. Opt H/Opt W is the shape TensorRT tunes its kernel selection for, so set it near the resolution you actually feed it - leaving it at 1022 while you run 512s wastes some of the benefit. Min H/Min W at the floor of 14 is the right default because it opens the whole range up. All three pairs must be divisible by 14 or the node refuses with a ValueError naming which pair is wrong.
Finally Workspace GB, default 4, minimum 1. That's TensorRT's scratch memory budget during the build. More workspace gives the builder more tactics to try, which usually means a faster engine and a longer build. Four is a sane default; drop it on a small card, raise it if you're chasing the last few percent.
The output is trt_model, a DEPTHACCEL_TENSORRT_MODEL handle for Estimate Depth (TensorRT). And since this is an endpoint node, you can queue [Load PyTorch] → [Export to ONNX] → [Build TensorRT Engine] with nothing attached and just let it write the file.
The two things that will bite you
Engines are tied to the TensorRT version and the GPU that built them. Not "usually compatible" - tied. This pack handles the version half properly: the builder writes a .version sidecar next to the .trt recording the TRT version, and the loader checks it and raises a clear error telling you to rebuild if they diverge. So after a pip install -U tensorrt, or after moving the file to another machine with a different card, expect to rebuild. Engines built by someone else's tooling have no sidecar and skip the check, which means a mysterious deserialize failure is your problem to diagnose.
Build time and log noise. First builds genuinely take minutes, and the TensorRT log lines scroll by the whole time. The console prints when parsing finishes and when the build finishes, so you can tell the difference between "working" and "hung."
Install
TensorRT is optional and commented out in the pack's requirements.txt, so ComfyUI Manager won't bring it in for you:
python -m pip install tensorrt onnx onnxslim
onnx is needed to parse the graph, onnxslim for the export side if you're doing the whole chain from scratch, and tensorrt is the compiler. This is the most invasive of the optional dependencies - it's a big wheel that wants a CUDA runtime matching your driver, and it goes into the same unisolated venv as your torch. If a system-wide torch upgrade starts failing after this, that's the blamed suspect, and uninstalling tensorrt is the test.
The full pipeline, once:
[Load Depth Model (PyTorch)] → [Export to ONNX] → [Build TensorRT Engine] → [Estimate Depth (TensorRT)]
Note what's missing: no fuse step, and after this runs you can start your future sessions at Load Depth Model (TensorRT) directly. The .trt lives in ComfyUI/models/depthanything/ alongside the checkpoints, and the engine dropdown picks up .trt, .engine, and .plan files alike.
Inputs (8)
| Name | Type | Default | Description |
|---|---|---|---|
| onnx_model | DEPTHACCEL_ONNX_MODEL | — | |
| min_h | INT | 14 | — |
| min_w | INT | 14 | — |
| opt_h | INT | 1022 | — |
| opt_w | INT | 1022 | — |
| max_h | INT | 2016 | — |
| max_w | INT | 2016 | — |
| workspace_gb | INT | 4 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| trt_model | DEPTHACCEL_TENSORRT_MODEL | — |