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

Depth Anything Tensorrt ⚡

The fastest depth map in ComfyUI, once you've built the engine

By yuvraj108c·Created 2 years ago·Updated 3 months ago· 134
Depth Anything Tensorrt ⚡
  • images
  • IMAGE
engine

This is the "just give me a grayscale depth map" node. Drop an image in, get a 0–1 depth image out, wire it into a depth ControlNet or a parallax workflow - that's the whole job, and it does it at 30+ fps on a 4090 instead of the few seconds the default comfyui_controlnet_aux preprocessor takes. The README claims up to 14x faster, and for depth specifically that's the honest end of the range.

The catch is in the name: TensorRT isn't a model, it's a compiled engine. Before this node will show you anything, you have to build one engine for your GPU. That's the one-time setup step in this pack (see the Engine Builder article), and it's also the thing that trips most people up, so it's worth understanding before you install.

How it works

Depth Anything (v1, v2, and the newer stuff) is a Vision Transformer that predicts how far every pixel is from the camera. The pack takes one of those models, converts it to ONNX, and compiles it into a TensorRT engine - NVIDIA's whole trick for turning a neural net into hardware-tuned kernels. Once it's an engine, inference is dramatically cheaper than running the same model through raw PyTorch.

Looking at the source, this node resizes your image to a fixed 518×518 input, runs each frame through the engine on a CUDA stream, then min-max normalizes the raw output to 0–255 and resizes it back to your original dimensions. The 0–1 grayscale image you get is exactly what a depth ControlNet wants: relative depth, brighter = closer. One neat detail - if the engine name contains "metric" (the real-world-scale v2 models), the node inverts the map so closer objects still come out brighter. If it contains "DA3", it runs the Depth Anything v3 postprocessing path instead, which converts inverse depth back to linear.

The inputs and outputs that matter

  • images - your IMAGE batch. Video frames work fine; it'll churn through them one at a time with a progress bar.
  • engine - a dropdown of every .engine file in ComfyUI/models/tensorrt/depth-anything. This list is read from disk at startup, so it'll be empty until you've built at least one engine. If you add one later, refresh the UI or hit r.

Output is a single IMAGE, which is why this is a drop-in replacement for any other depth preprocessor.

Installing it

ComfyUI Manager handles it: search "Depth Anything TensorRT" and install. Or the manual route:

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 dependency is tensorrt itself - the pip package assumes a matching NVIDIA driver, CUDA, and an actual TensorRT install. This is a strictly NVIDIA, CUDA stack; it won't work on AMD or Apple silicon. The other requirements are opencv-python, polygraphy (used to compile engines), and huggingface_hub (to download models).

Where people get burned

The #1 mistake is installing the pack, seeing an empty engine dropdown, and assuming it's broken. It isn't - you just haven't built an engine yet. Run the Engine Builder node once (it downloads the ONNX and compiles it in the background), refresh, and the dropdown fills in.

Second: engines are compiled for your exact GPU. An engine built on one machine won't load on another, and a build that takes a few minutes on first run is normal. Third, on a low-VRAM card, the Large models can OOM - use the small or base builds with FP16 enabled, which is the default anyway. Community reports on similar yuvraj TensorRT packs confirm the pattern: the models are fine, the engine-building step on Windows is where people stall.

If all you need is depth for ControlNet, this node is the one to reach for. If you want raw depth numbers for 3D work instead, you want the Advanced sibling - that's the next article.

Categorytensorrt

Inputs (2)

NameTypeDefaultDescription
imagesIMAGEInput image or batch of images to estimate depth for.
engineCOMBOTensorRT engine file to use for inference. Engine names containing 'DA3' use Depth Anything V3, others use V2/V1 postprocessing.

Outputs (1)

NameTypeDescription
IMAGEIMAGENormalized depth map as a grayscale image (0-1 range). For metric engines, depth is inverted so closer objects are brighter.