0Pricing
CUDA Academy · Aula

Capturando trabalho em um grafo

Registrando um fluxo em um grafo CUDA.

Capturando trabalho em um grafo é uma aula grátis de CUDA Academy no CoddyKit. Esta é a aula 3 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de CUDA Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de CUDA Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

What a CUDA Graph Is

A CUDA graph records a whole sequence of kernels and copies as one reusable unit of work you can submit again and again.

Launches Add Up

Each individual kernel launch has a tiny CPU overhead. Across thousands of launches per iteration, that cost becomes real.

Define Once, Run Many

A graph lets you describe the work once, then replay it cheaply, paying the setup cost a single time.

Stream Capture Mode

The easiest way to build one is stream capture: you record the normal launches you already issue into a stream.

cudaStreamBeginCapture(stream, cudaStreamCaptureModeGlobal);

Issue Work Normally

Between begin and end, you launch kernels and copies as usual. Nothing runs yet; the operations are recorded, not executed.

kernelA<<<g, b, 0, stream>>>(d);
kernelB<<<g, b, 0, stream>>>(d);

End the Capture

You stop recording with cudaStreamEndCapture, which hands back a cudaGraph_t describing all the work.

cudaGraph_t graph;
cudaStreamEndCapture(stream, &graph);

Dependencies Inferred

Capture figures out the dependencies between operations automatically from how you used the stream.

Instantiate Before Running

A graph is just a description. You compile it into a runnable graph exec object before you can launch it.

cudaGraphExec_t exec;
cudaGraphInstantiate(&exec, graph, 0);

Building Graphs by Hand

You can also add nodes explicitly with the graph API for full control over structure and edges.

cudaGraphAddKernelNode(&n, graph, deps, 1, &params);

Multiple Streams, One Graph

Capture can span several streams, so independent branches that run concurrently all land in the same graph.

Reuse Across Many Iterations

Once instantiated, the same exec object is launched repeatedly, which is exactly where graphs earn their keep.

Quick Check

What does cudaStreamEndCapture produce?

Recap: Capturing Graphs

Wrap launches in stream capture to record a cudaGraph_t, instantiate it once, and capture infers the dependencies for you. Great progress! 🎉

Perguntas Frequentes

A aula “Capturando trabalho em um grafo” é grátis?

Sim — o texto completo de “Capturando trabalho em um grafo” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de CUDA Academy, atualize para CoddyKit PRO. O curso de CUDA Academy inclui 4 aulas no total.

O que vou aprender em “Capturando trabalho em um grafo”?

Registrando um fluxo em um grafo CUDA. Você pratica CUDA Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar CUDA Academy?

Nenhuma experiência prévia é necessária. CUDA Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 3 de 4.

Quanto tempo leva a aula “Capturando trabalho em um grafo”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de CUDA Academy?

Sim. Cada aula de CUDA Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Lançando kernels a partir de um kernel
  2. Quando o paralelismo dinâmico compensa
  3. Capturando trabalho em um grafo
  4. Reproduzindo grafos para reduzir sobrecarga
← Voltar para CUDA Academy