What is nvcc in CUDA?
The CUDA compiler driver, which splits your file into host code for the system compiler and device code for ptxas.
nvcc conducts more than it compiles. One .cu file gets preprocessed twice. The device half becomes PTX, ptxas assembles that into a cubin for a named architecture, and both go into a fatbinary. The host half goes to your system compiler, g++ or cl.exe, with the fatbinary embedded in it and every <<<>>> launch rewritten into ordinary runtime API calls. Two things follow from that shape. nvcc needs a host compiler it can drive, which is why day 3's build line on our verification node carries -ccbin (the box has no CUDA toolkit installed, so both nvcc and its host compiler come from a self-contained toolchain in /tmp). And you can watch the whole trajectory yourself with nvcc --dryrun, documented as "List the compilation sub-commands without executing them", which prints every preprocess, cicc, ptxas, fatbinary and host-compiler step in order.
Six flags carry this course.
| Flag | What it does | Where it shows up |
|---|---|---|
-arch=sm_75 |
Cubin for Turing plus compute_75 PTX beside it |
Every target here. Day 3's binary reports __CUDA_ARCH__ 750 |
-arch=native |
Code for the GPUs nvcc can see, and "no PTX program will be generated for this option" | The trap. The binary is quietly non-portable |
-O3 |
"Specify optimization level for host code", so the host half only | Every target here |
-Xptxas -v |
"Specify options directly to ptxas"; -v reports registers, spills and shared memory per kernel |
Day 17, where the occupancy arithmetic starts |
-ccbin <dir> |
"Specify the directory in which the default host compiler executable resides" | Any box whose default host compiler is missing |
--list-gpu-arch |
Prints the architectures this toolkit accepts. On 13.3.0 the list starts at compute_75 |
Checking whether your card is above the floor |
The -O3 row surprises people. It tunes the host half; device optimisation goes through -Xptxas, which is a different compiler with its own options.
Then there is the question with 360,646 views: nvcc --version and nvidia-smi print different CUDA versions on a machine where nothing is broken. They are two pieces of software from two packages. nvcc ships in the toolkit and tells you what compiled your binary. nvidia-smi ships with the driver and its header reports the highest CUDA runtime that driver will accept, which is a ceiling, not an installation. A toolkit under the ceiling is the normal, working case.
Measured
On a Tesla T4 (driver 595.84, CUDA 12.6, V12.6.85, built with nvcc -O3 -arch=sm_75), day 3 printed runtime version 12.6 and max CUDA the driver takes 13.2 in the same block, with __CUDA_ARCH__ coming back as 750 from the device. Captured 2026-08-30 on the project's verification node. Three numbers, three meanings, and the driver's own package version (595.84) is a fourth that appears nowhere in that list. Full run behind How to set up CUDA.
That gap is also a constraint we live with: this node's driver stops at 13.2, and CUDA 13.3 Update 1 needs 610.43.02, so the course's own code is verified on 12.6 and every lesson says so.
Related terms
ptxas · PTX · gencode · separate compilation · CUDA runtime API · compute capability · JIT compilation
Where you meet this
Day 3, how to set up CUDA, is where the flag and the version confusion get settled; nvcc and nvidia-smi disagree takes the version half on its own. Day 1 is the smallest file nvcc has to split in two. Day 17 turns -Xptxas -v into occupancy numbers, and day 69 replaces -arch with -gencode once one binary has to serve several cards. When the command is not there at all, see nvcc: command not found; when it refuses your architecture, see nvcc fatal: Unsupported gpu architecture.
Sources
- nvcc manual, compilation trajectory,
--dryrun,-O,-Xptxas,-ccbin: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html (checked 2026-08-30) -archshorthand, thesm_75default, andnativegenerating no PTX: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-architecture-arch (checked 2026-08-30)- The 360,646-view question behind the version confusion: https://stackoverflow.com/questions/53422407/different-cuda-versions-shown-by-nvcc-and-nvidia-smi (checked 2026-08-29)
- What
cudaRuntimeGetVersionandcudaDriverGetVersioneach return: https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART____VERSION.html (checked 2026-08-30)
Byline
Author and reviewer are unassigned. This entry publishes when two different named people have signed it; the written and last-checked dates are set then.