CUDA and TensorRT are not alternatives. CUDA is the general-purpose GPU compute layer; TensorRT is an inference optimisation and runtime layer that emits CUDA work underneath. Asking which one to “pick” for inference is like asking whether to use an engine or a gearbox.
The useful question is a split, not a choice: which parts of your inference path should be delegated to a graph-level optimiser — layer fusion, precision calibration, kernel autotuning — and which parts genuinely need bespoke CUDA kernels or TensorRT plugins.
What does “CUDA vs TensorRT” mean in practice?
In deployment, it means deciding how much of your model graph you hand over. TensorRT ingests a network (usually via ONNX), fuses layers, picks kernels by autotuning against your actual GPU, and can calibrate to FP16 or INT8 at a chosen accuracy budget. The output is still CUDA execution — you have not left CUDA, you have stopped hand-writing it.
The divergence point we see most often is a team writing custom CUDA for an operation TensorRT would already fuse and tune, then spending engineering weeks to land slower than the runtime default. That is the expensive version of this misconception, and it is avoidable with an hour of profiling.g.
Where each layer earns its place
| Concern | Delegate to TensorRT | Keep in custom CUDA |
|---|---|---|
| Standard conv / attention / GEMM blocks | Yes — fusion and autotuning beat hand-rolled kernels in most cases | No |
| FP16 / INT8 precision calibration | Yes — calibration is built in | Only for unusual quantisation schemes |
| Unsupported or custom operations | No — the graph will break or fall back | Yes, as a TensorRT plugin |
| Pre/post-processing, data movement | Partially | Often yes, or move to CUDA streams / DALI |
| Vendor-neutral serving requirement | No — TensorRT is NVIDIA-only | CUDA alone is already NVIDIA-only; portability needs ONNX Runtime or similar |
Inference optimization trades flexibility for throughput
TensorRT compiles models into fixed-precision execution graphs that sacrifice dynamic control flow and arbitrary layer insertion in exchange for 2–5× faster per-token generation. TensorRT commits the serving layer as well — engine files are built per GPU architecture and per TensorRT version, so the artefact you deploy is tied to a narrower target than a CUDA binary. If vendor neutrality is a live requirement, price that commitment explicitly rather than discovering it at the next hardware refresh.
Before choosing a layer to optimise, establish whether the bottleneck is the graph, the kernels, or data movement. Those three have different fixes, and only the first is reliably solved by TensorRT. Our broader treatment of that diagnostic sits in the GPU engineering practice pages, where the same split drives audit scoping.
The open question for most teams is not which layer to use but how much of their graph is genuinely custom — and that number is usually smaller than the codebase suggests.