0Pricing
CUDA Academy · Ders

Aygıtları Listeleme ve Seçme

cudaSetDevice ve GPU başına bağlamlar

Aygıtları Listeleme ve Seçme, CoddyKit'te ücretsiz bir CUDA Academy dersidir. Bu, 4 dersinin 1. dersidir. Aşağıdan dersin tamamını ücretsiz okuyabilir, sonra tarayıcıda yerleşik kod editörü ve 7/24 yapay zeka koçu ile uygulamalı olarak pratik yapabilirsin. Bu, CUDA Academy öğrenme yolunun bir parçasıdır ve ilerlemeniz web ve CoddyKit uygulaması arasında senkronize olur. CUDA Academy kursu toplamda 4 dersten oluşur.

Bu dersin bazı bölümleri henüz çevrilmemiş olup İngilizce olarak gösterilmektedir.

More Than One GPU

A single machine can hold several GPUs. To use them all, your program first needs to discover how many devices are present before it sends any work.

Counting the Devices

One call tells you how many GPUs the runtime can see. cudaGetDeviceCount writes that number into an int you hand it.

int count;
cudaGetDeviceCount(&count);

Devices Are Numbered

Each GPU gets an integer id from 0 up to count minus one. That device id is how you point the runtime at one specific card.

Picking the Active Device

You choose which GPU your next calls target with cudaSetDevice. After this, allocations and launches go to that card.

cudaSetDevice(1);

There Is a Current Device

At any moment exactly one GPU is the current device for the calling thread. Every cudaMalloc or kernel launch lands on whatever device is current.

Inspecting a Device

Before trusting a GPU you can read its specs. cudaGetDeviceProperties fills a struct with name, memory size, and compute capability.

cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);

Reading the Properties

The properties struct is rich. Fields like name and totalGlobalMem help you pick the best card or skip one that is too small.

Each Device Owns Its Memory

A pointer from cudaMalloc belongs to whichever GPU was current then. Using it while another device is current is an error waiting to happen.

Per-Device Contexts

Behind each GPU sits a context that holds its allocations and streams. Switching the current device switches you into that device's context.

Looping Over All GPUs

A common pattern is a loop that calls cudaSetDevice for each id, then does setup on that card. This is how you spread work across every device.

for (int d = 0; d < count; d++) {
  cudaSetDevice(d);
}

Restore Before You Leave

If a helper changes the current device, switch it back when done. Leaving the current device changed can surprise the rest of your code.

Quick Check

Recall which call chooses the GPU your next allocations and launches will use.

Recap

You count GPUs, pick one with cudaSetDevice, and inspect it with properties. Each device owns its own memory and context. Next: splitting work across them. ✨

Sıkça Sorulan Sorular

“Aygıtları Listeleme ve Seçme” dersi ücretsiz mi?

Evet — “Aygıtları Listeleme ve Seçme” dersin tüm metni burada web'de ücretsiz olarak okunabilir. Etkileşimli olarak pratik yapmak (yerleşik kod editörü ve 7/24 yapay zeka koçu) ve CUDA Academy kursunun geri kalanını açmak için CoddyKit PRO'ya yükselt. CUDA Academy kursu toplamda 4 dersten oluşur.

“Aygıtları Listeleme ve Seçme” dersinde ne öğreneceğim?

cudaSetDevice ve GPU başına bağlamlar CUDA Academy ile uygulamalı kodu tarayıcıda doğrudan çalıştırarak pratik yaparsın ve 7/24 yapay zeka koçu dersi çalışırken sorularını yanıtlar.

CUDA Academy öğrenmeye başlamak için deneyim gerekli mi?

Önceden deneyim gerekmez. CoddyKit'te CUDA Academy, başlangıçtan ileri seviyeye kadar yapılandırıldığı için buradan başlayabilir veya başından başlayıp kendi hızında ilerleme yapabilirsin. Bu, 4 dersinin 1. dersidir.

“Aygıtları Listeleme ve Seçme” dersi ne kadar sürer?

Çoğu CoddyKit dersi yaklaşık 5–10 dakika sürer. Her biri kısa ve etkileşimli olduğu için sabit ilerleme yaparsın ve web ile uygulama arasında tam olarak bıraktığın yerden devam edebilirsin.

Bu CUDA Academy dersinde kod yazıp çalıştırabilir miyim?

Evet. Her CUDA Academy dersi yerleşik bir kod editörü içerir, bu sayede tarayıcıda gerçek kod yazıp çalıştırabilir ve anlık yapay zeka geri bildirimi alırsın — yerel kurulum gerekli değildir.

Bu kursun tüm dersleri

  1. Aygıtları Listeleme ve Seçme
  2. İşi GPU'lar Arasında Bölümlendirme
  3. Eşler Arası Bellek Erişimi
  4. NCCL ile Çoklu GPU
← CUDA Academy Sayfasına Dön