0Pricing
CUDA Academy · レッスン

ピアツーピアメモリアクセス

NVLink 経由で GPU 間を直接コピー

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

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

The Slow Detour

Moving data from one GPU to another usually bounces through the CPU's memory first. That round trip is slow and wastes the host's bandwidth.

GPUs Talking Directly

Modern GPUs can skip the CPU entirely. Peer-to-peer access lets one GPU read and write another's memory over a direct link.

The NVLink Highway

The fast link between cards is often NVLink, far quicker than the shared PCIe bus. P2P transfers ride this highway when it is available.

Check Before You Trust

Not every pair of GPUs can do P2P. Ask first with cudaDeviceCanAccessPeer, which reports whether one device may reach another.

int can;
cudaDeviceCanAccessPeer(&can, 0, 1);

Turn On Access

Permission is off by default. While GPU 0 is current, call cudaDeviceEnablePeerAccess to let it reach into GPU 1's memory.

cudaSetDevice(0);
cudaDeviceEnablePeerAccess(1, 0);

Access Is One-Way

Enabling peer access grants only the direction you ask for. For GPU 1 to read GPU 0, you must enable that direction too, from device 1.

Copying Peer to Peer

To move a buffer directly between cards, use cudaMemcpyPeer. You name the destination pointer and device plus the source pointer and device.

cudaMemcpyPeer(dst, 1, src, 0, bytes);

Kernels Reading Across

With access enabled, a kernel on GPU 0 can dereference a pointer that lives on GPU 1. The hardware fetches it over the peer link transparently.

When P2P Is Not There

If two cards cannot peer, the runtime quietly falls back to staging through host memory. You still get a copy, just at the slower PCIe rate.

Async Peer Copies

Peer transfers can overlap other work. Pair cudaMemcpyPeerAsync with a stream so the copy runs while kernels keep computing.

cudaMemcpyPeerAsync(dst, 1, src, 0, bytes, stream);

Turn It Off When Done

Peer access uses resources, so release it when finished. cudaDeviceDisablePeerAccess tears down the link you opened earlier.

cudaDeviceDisablePeerAccess(1);

Quick Check

Recall the benefit of peer-to-peer access between two GPUs.

Recap

P2P lets GPUs share memory directly, ideally over NVLink. Check support, enable access per direction, then use cudaMemcpyPeer. Next: scaling with NCCL. ✨

よくある質問

「ピアツーピアメモリアクセス」レッスンは無料ですか?

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

「ピアツーピアメモリアクセス」で何を学びますか?

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

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

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

「ピアツーピアメモリアクセス」レッスンにはどのくらい時間がかかりますか?

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

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

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

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

  1. デバイスの列挙と選択
  2. GPU 間のワーク分割
  3. ピアツーピアメモリアクセス
  4. NCCL によるマルチ GPU
← CUDA Academyに戻る