nvcc ile Derleme
nvcc'nin ana bilgisayar ve cihaz kodunu nasıl ayırdığını öğrenin.
nvcc ile Derleme, CoddyKit'te ücretsiz bir CUDA Academy dersidir. Bu, 4 dersinin 3. 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.
Meet nvcc
The CUDA compiler is called nvcc. It takes your .cu file with mixed CPU and GPU code and turns it into one runnable program. 🛠️
Two Kinds of Code
A .cu file holds two worlds: host code that runs on the CPU and device code that runs on the GPU. nvcc must handle each one differently.
The Great Split
nvcc splits your source automatically. It hands the host portions to your normal C++ compiler and keeps the device portions for itself.
Compiling Device Code
For the GPU side, nvcc generates a special assembly called PTX, then turns it into machine code your specific GPU can execute.
The Host Compiler
nvcc does not compile CPU code itself. It quietly calls your system's host compiler, like g++ or clang, to handle the ordinary C++.
Your First Build Command
Compiling looks just like g++. Point nvcc at your .cu file and name the output with the -o flag.
nvcc hello.cu -o helloTargeting an Architecture
The -arch flag tells nvcc which GPU generation to build for. Matching it to your card produces faster, fully optimized device code.
nvcc -arch=sm_80 hello.cu -o helloCompute Capability
That sm number is a compute capability, a label for a GPU's feature set. sm_80 means an Ampere card; older cards use smaller numbers.
Fatbins for Many GPUs
nvcc can pack code for several architectures into one fatbinary, so the same executable runs well on different GPUs without rebuilding.
Familiar Optimization Flags
Many g++ habits carry over. nvcc accepts -O levels and -g for debugging, passing them along to the right compiler stage.
nvcc -O3 hello.cu -o helloLinking CUDA Libraries
Need a tuned library like cuBLAS? You link it just as in g++, adding the library name with an -l flag on the nvcc command.
nvcc app.cu -lcublas -o appQuick Check
Let us check how nvcc divides the work.
Recap
You learned that nvcc splits a .cu file, compiles device code to GPU machine code, and hands host code to g++. The -arch flag targets your card. 🎯
Sıkça Sorulan Sorular
“nvcc ile Derleme” dersi ücretsiz mi?
Evet — “nvcc ile Derleme” 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.
“nvcc ile Derleme” dersinde ne öğreneceğim?
nvcc'nin ana bilgisayar ve cihaz kodunu nasıl ayırdığını öğrenin. 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 3. dersidir.
“nvcc ile Derleme” 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
- Sürücü, Çalışma Zamanı ve Araç Seti Sürümleri
- nvidia-smi'yi Uzman Gibi Okuyun
- nvcc ile Derleme
- Merhaba GPU: İlk .cu Dosyanız