Home Knowledge Base CUDA Graphs

CUDA Graphs are a mechanism to capture a sequence of GPU operations as a graph and replay them with minimal CPU overhead — eliminating the per-kernel launch overhead that limits performance for workloads with many small GPU operations.

The Problem CUDA Graphs Solve

CUDA Graph Concepts

Creating a CUDA Graph

cudaGraph_t graph;
cudaGraphExec_t instance;

// Method 1: Stream Capture
cudaStreamBeginCapture(stream, cudaStreamCaptureModeGlobal);
kernel_A<<<grid, block, 0, stream>>>();
cudaMemcpyAsync(dst, src, size, kind, stream);
kernel_B<<<grid, block, 0, stream>>>();
cudaStreamEndCapture(stream, &graph);

// Instantiate and launch repeatedly
cudaGraphInstantiate(&instance, graph, 0);
for (int iter = 0; iter < N; iter++)
    cudaGraphLaunch(instance, stream);

Performance Benefits

Operator Fusion

CUDA Graphs and operator fusion are the key to closing the gap between raw GPU compute and actual inference throughput — at batch size 1, these optimizations are often the difference between 1ms and 5ms latency, directly determining real-time applicability of AI applications.

cuda graphexecution graphoperator fusionkernel fusioncuda graph optimization

Explore 500+ Semiconductor & AI Topics

From EUV lithography to CUDA optimization — search the full knowledge base or chat with our AI assistant.