Nodes/ComfyUI Depth Anything TensorRT/Depth Anything Tensorrt Engine Builder ⚡
ComfyUI Node

Depth Anything Tensorrt Engine Builder ⚡

The boring node everything else in this pack depends on

By yuvraj108c·Created 2 years ago·Updated 3 months ago· 134
Depth Anything Tensorrt Engine Builder ⚡
    • message
    model_versionv1_large
    custom_engine_name
    use_fp16true
    custom_onnx_path

    Every node in this pack is useless until you've done this one once. The Engine Builder downloads a Depth Anything model and compiles it into a TensorRT engine optimized for your exact GPU - the step that turns "depth map in seconds" into "depth map in milliseconds." It's the least glamorous node here and the one nobody can skip. The good news: you build an engine once, and it's reused for every subsequent run.

    How it works

    Pick a model, run the node, wait. Under the hood it does three things. First, it reads a model catalog from the pack's config/models.json - fourteen entries covering Depth Anything v1/v2 (small, base, large), the two v2 metric variants, Distill-Any-Depth, and the two Depth Anything v3 models. Second, it downloads the matching ONNX file through Hugging Face Hub into ComfyUI/models/onnx/depth-anything (it skips the download if the file's already there). Third, it calls the pack's export_trt script - built on polygraphy, which is why that's in the requirements - to compile the engine into ComfyUI/models/tensorrt/depth-anything.

    The node is careful not to waste your time: if the target engine already exists, it tells you so and does nothing. That's why the output is just a STRING status message - this is a build-and-report node, not a data pipeline.

    The inputs that matter

    • model_version - the dropdown with all fourteen options. If you're on a 4090 or better, v2_large is the sweet spot the community has landed on for years. On a card with less VRAM, start with v2_base or v1_small; Large can OOM on 8–12 GB cards.
    • use_fp16 - defaults to on, and you should leave it on. Half the memory, roughly the same quality, and it's how the README's benchmark numbers were produced. Turn it off only if you hit stability problems.
    • custom_engine_name - leave it empty unless you know you want a specific filename. It also matters for behavior: the inference nodes read the engine name to decide postprocessing (names containing "DA3" get v3 handling, and "metric" triggers depth inversion), so a custom name that strips those markers will change how your results come out.
    • custom_onnx_path - a path to your own ONNX if you've exported a model the catalog doesn't list. Rarely needed.

    Installing it

    Same pack, same install. Manager, or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/yuvraj108c/ComfyUI-Depth-Anything-Tensorrt
    cd ComfyUI-Depth-Anything-Tensorrt
    pip install -r requirements.txt
    

    The heavy lift is tensorrt - the pip package expects a working TensorRT install on top of an NVIDIA driver and matching CUDA. No CUDA, no engines. AMD and Apple silicon are out. The first build for a given model also takes a real chunk of time and CPU while polygraphy hammers through optimization passes, so don't panic when the status message takes minutes to appear.

    Where people get burned

    The big one: engines are hardware-specific. A TensorRT engine is compiled for your GPU's exact architecture and TensorRT version. Build it on one machine and it won't load on another - move machines and you rebuild. Relatedly, upgrading your TensorRT/CUDA versions can invalidate old engines, which is why the "already exists, delete if you want to rebuild" message exists.

    Second, the fiddly bit on Windows. Community threads on yuvraj's other TensorRT packs (RIFE, DWPose) make it clear the models are fine - it's the engine-building step on Windows that stalls people, usually a TensorRT/CUDA version mismatch. If the build fails, check your console log for the actual error rather than re-running blindly.

    Third: after a successful build, refresh the UI (hit r). The engine dropdown on the inference nodes is populated at load time, so a freshly built engine won't appear until you refresh. And if you're staring at an empty dropdown with no engine built, that's not a bug - it's this node's entire reason to exist.

    Categorytensorrt

    Inputs (4)

    NameTypeDefaultDescription
    model_versionCOMBOv1_largeSelect the Depth Anything model version and size. Larger models provide better quality but require more VRAM.
    custom_engine_nameSTRINGOptional custom name for the TensorRT engine file. If empty, will use the default name based on the model.
    use_fp16BOOLEANtrueEnable FP16 precision for faster inference and lower VRAM usage. Disable if you experience stability issues.
    custom_onnx_pathSTRINGOptional path to a custom ONNX model file. If provided, will use this instead of downloading the predefined model.

    Outputs (1)

    NameTypeDescription
    messageSTRINGStatus message indicating whether the engine was built successfully, already exists, or encountered an error.