nvcc Command: Compile CUDA in CI
nvcc compiles CUDA C/C++ into host code plus GPU device binaries.
nvcc is NVIDIA's CUDA compiler driver. It splits source into host and device code, compiling device kernels for one or more GPU architectures and handing host code to the system C++ compiler. CI for GPU code pins target architectures with -arch/-gencode.
Common flags
-o NAME- name the output executable/object-arch=sm_80- target a specific GPU compute capability-gencode arch=compute_80,code=sm_80- emit PTX + SASS for an arch (repeatable)-c- compile to an object file without linking-I DIR/-L DIR/-lNAME- header / lib path / link library-O3- optimize host and device code-Xcompiler "-Wall"- pass flags through to the host compiler
Example in CI
Compile a CUDA program for two GPU architectures in a GPU CI job:
shell
nvcc -O3 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_90,code=sm_90 kernel.cu -o appCommon errors in CI
- nvcc fatal: Unsupported gpu architecture 'compute_XX' - toolkit too old for that arch
- no kernel image is available for execution on the device - runtime arch mismatch with -arch
- cuda_runtime.h: No such file or directory - CUDA toolkit not installed / wrong -I
- unsupported GNU version! gcc versions later than N are not supported - host compiler too new
Key takeaways
- Pin GPU targets with
-arch/-gencodeto match the runtime hardware. - "no kernel image available" means the built arch does not match the GPU.
- nvcc needs a compatible host compiler; very new gcc/clang can be rejected.
Related guides
gcc Command: Compile C in CIgcc is the GNU C compiler driver. Reference for -c, -o, -I, -L, -l, -Wall, -O2, -std, and the header/library…
clang Command: Compile C/C++ in CIclang is the LLVM C/C++ compiler. Reference for -c, -o, -I, -std, -fsanitize, -Weverything, and the diagnosti…
cmake Command: Configure C++ Builds in CIcmake configures and builds C/C++ projects. Reference for -S, -B, -G, -D, --build, --target, --preset, and th…