cuDNN, the CUDA Deep Neural Network library, is a proprietary NVIDIA library of GPU-accelerated primitives for deep neural networks, such as convolution, normalization, activation, pooling, recurrent layers and attention. Among AI frameworks & tools, it sits below the user-facing frameworks: PyTorch, TensorFlow and JAX do not write most of their GPU kernels themselves but call cuDNN to execute the heavy operators on NVIDIA hardware.
The library matters because the same mathematical operation can run through many different algorithms, and the fastest one depends on tensor shapes, data type, memory layout and GPU generation. cuDNN packages hand-tuned and runtime-compiled kernels, plus heuristics that select an algorithm, so framework developers get near-peak performance in artificial intelligence workloads without writing low-level CUDA code for every case.
How cuDNN executes neural network operations
cuDNN works as a host-side library that launches GPU kernels on behalf of a framework. The framework describes an operation with descriptors (tensor dimensions, strides, data type, convolution padding and stride), asks cuDNN which execution engines can handle it, and then runs the chosen engine with a caller-provided workspace buffer in GPU memory.
Since version 8, the core interface is the graph API: an operation is expressed as a small graph of nodes, for example a convolution followed by a bias addition and a ReLU activation. cuDNN can then fuse several operations into one kernel, which avoids writing intermediate tensors to memory. The open-source cuDNN frontend wraps this C interface in C++ and Python, and it is the recommended entry point for new code. The older legacy API, with fixed calls such as a single convolution forward function, is deprecated in cuDNN 9.
The table below summarizes the main stages of a single cuDNN call as a framework performs it.
| Stage | What happens | Why it matters |
|---|---|---|
| Describe | Tensors and the operation graph are defined | Shapes and layout decide which kernels apply |
| Query engines | Heuristics rank candidate engines and configurations | A good ranking avoids slow trial runs |
| Finalize plan | An execution plan is built, sometimes compiled at runtime | Fused kernels may need compilation time |
| Execute | The plan runs on a CUDA stream with a workspace | Workspace size limits the available algorithms |
| Cache | The framework stores the plan for repeated shapes | Repeated steps skip selection overhead |
Operations and algorithms inside cuDNN
cuDNN covers the operators that dominate deep learning compute time. Convolutions have the richest choice of algorithms, because each trades memory, numerical behavior and speed differently. Implicit GEMM maps convolution to matrix multiplication without materializing the expanded input, while Winograd and FFT-based methods reduce arithmetic for specific filter sizes at the cost of extra workspace and slightly different rounding.
The following table lists the major operation families and the algorithmic options cuDNN offers for them.
| Operation family | Typical algorithms or features | Common use |
|---|---|---|
| Convolution | Implicit GEMM, Winograd, FFT, direct | Image models, audio models, U-Nets |
| Matrix multiplication | Graph API matmul with fused epilogues | Linear layers with bias and activation |
| Attention | Fused scaled dot-product attention, flash-style | Transformers and language models |
| Normalization | Batch, layer, instance and RMS normalization | Stabilizing training |
| Pointwise and reduction | Activations, softmax, fused elementwise ops | Epilogues after matmul or convolution |
| Recurrent layers | LSTM and GRU kernels | Sequence models and older speech systems |
Precision support follows the hardware. cuDNN uses Tensor Cores for FP16 and BF16, enables TF32 on Ampere and newer GPUs, and supports FP8 on Hopper and later architectures for selected operations. Lower precision usually doubles throughput or better, but it requires loss scaling or careful accumulation to keep training stable.
cuDNN compared with related GPU libraries
cuDNN is one layer in a stack of NVIDIA and third-party libraries, and confusing these layers is a frequent source of misunderstanding. cuDNN supplies operator kernels, while other tools handle linear algebra, communication, model compilation or deployment.
The comparison below places cuDNN next to the neighbors that practitioners most often mix it up with.
| Library | Role | Relationship to cuDNN |
|---|---|---|
| cuDNN | Neural network operator kernels | Called by frameworks for convolution, attention, normalization |
| cuBLAS | Dense linear algebra (GEMM) | Complements cuDNN for plain matrix products |
| NCCL | Multi-GPU collective communication | Handles gradients between GPUs, not compute |
| TensorRT | Inference optimizer and runtime | Builds optimized engines, partly using its own kernels |
| Triton | Language for writing custom GPU kernels | Alternative when cuDNN lacks a fused pattern |
| MIOpen | AMD equivalent within ROCm | Same purpose on AMD GPUs |
| oneDNN | Intel library for CPUs and GPUs | Same purpose on Intel hardware |
Compilers such as XLA and PyTorch’s TorchInductor increasingly generate their own kernels, yet they still delegate convolutions and attention to cuDNN when its kernels are faster. The choice is therefore not cuDNN or a compiler, but which backend wins for each operator.
Installing and configuring cuDNN in practice
Most users never install cuDNN by hand, because framework packages bundle a compatible build. PyTorch wheels, for instance, depend on an NVIDIA cuDNN wheel matched to the CUDA major version. Manual installation matters for custom builds, containers and C++ applications, where the cuDNN version must match the CUDA toolkit major version and the GPU driver must be recent enough.
Framework settings control how cuDNN chooses algorithms. The table below covers the decisions that affect speed and reproducibility most.
| Situation | Recommended setting | Reason |
|---|---|---|
| Fixed input shapes in training | Enable autotuning (benchmark mode) | Measured selection finds the fastest kernel |
| Variable input shapes | Keep autotuning off | Re-tuning every new shape costs time |
| Bitwise reproducibility needed | Request deterministic algorithms | Some fast kernels use nondeterministic atomics |
| Tight GPU memory | Limit workspace size | Prevents out-of-memory errors, may slow kernels |
| Mixed-precision training | Use BF16 or FP16 with Tensor Cores | Large throughput gain on modern GPUs |
In PyTorch, these choices appear as the cudnn.benchmark and cudnn.deterministic flags. In TensorFlow, determinism is requested through an operation-determinism setting, and JAX reaches cuDNN through XLA.
Limitations and common mistakes
cuDNN is fast within its scope, but its scope is narrow. It runs only on NVIDIA GPUs, it is closed-source except for the frontend layer, and its license permits redistribution only under NVIDIA terms. These facts shape portability decisions for teams that also target AMD, Intel or Apple hardware.
- Version mismatch errors: a framework built against one cuDNN major version fails to load another; matching the bundled versions avoids this.
- Assuming determinism by default: identical runs can differ slightly unless deterministic algorithms are explicitly requested.
- Benchmark mode with dynamic shapes: autotuning every new batch size can make training slower, not faster.
- Ignoring memory layout: channels-last (NHWC) tensors often run faster with Tensor Cores than channels-first (NCHW) tensors.
- Expecting every fusion to exist: unsupported graph patterns fall back to separate kernels, so the speedup varies by model.
A plain-language summary
cuDNN is a toolbox of very fast building blocks for neural networks. It runs on NVIDIA graphics cards. Popular AI programs use it in the background. Most people never see it.
Think of a professional kitchen. The chef plans the meal, which is like the AI framework. cuDNN is the set of specialized machines that chop, mix and bake very quickly. The chef does not build those machines. The chef simply uses them. The key point is simple: cuDNN makes AI training and use much faster on NVIDIA hardware.
An example from practice
A medical imaging team trains a 3D U-Net segmentation model on CT scans with PyTorch on four NVIDIA data center GPUs. The first training run uses FP32 tensors in channels-first layout with default settings, and one epoch takes about 95 minutes.
The engineers make three changes that all act through cuDNN. They switch to BF16 mixed precision so convolutions use Tensor Cores, convert tensors to the channels-last layout, and enable benchmark mode because every training crop has the same fixed size. Each change lets cuDNN pick a faster convolution engine for the same shapes.
After the changes, one epoch takes roughly 40 minutes, and validation accuracy stays within normal run-to-run variation. For the final audit run, the team turns on deterministic algorithms and accepts a modest slowdown, so that regulators can reproduce the reported results exactly.