0Pricing
CUDA Academy · レッスン

ワークをグラフにキャプチャする

ストリームを CUDA グラフに記録する

「ワークをグラフにキャプチャする」はCoddyKit上の無料CUDA Academyレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはCUDA Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 CUDA Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

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! 🎉

よくある質問

「ワークをグラフにキャプチャする」レッスンは無料ですか?

はい。「ワークをグラフにキャプチャする」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、CUDA Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 CUDA Academyコースには全4レッスンが含まれています。

「ワークをグラフにキャプチャする」で何を学びますか?

ストリームを CUDA グラフに記録する ブラウザで直接実行するハンズオンコードでCUDA Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

CUDA Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのCUDA Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。

「ワークをグラフにキャプチャする」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このCUDA Academyレッスンでコードを書いて実行できますか?

はい。すべてのCUDA Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. カーネルからカーネルを起動する
  2. 動的並列処理が効果を発揮する場面
  3. ワークをグラフにキャプチャする
  4. グラフの再生でオーバーヘッドを削減
← CUDA Academyに戻る