Introduction
A .cubin file is the compiled form of CUDA
device code for one GPU architecture. NVIDIA calls it a CUDA binary, and its
documentation says a cubin is an ELF-formatted file, with executable code sections and
further sections for symbols, relocations and debug information. A program loads
cubin files at run time through the CUDA driver API, and by default the
nvcc compiler embeds them in the host executable.
A .fatbin file is a CUDA fat binary: a container that may hold several
cubin and PTX images, for different targets. When the
program runs, the CUDA runtime looks in the embedded fat binary for an image that suits
the GPU in the machine. The two formats are described together here because a fat
binary is a container for cubins and PTX.
Structure
A cubin follows the ELF layout, so the usual ELF tools see its headers and sections. The machine code inside is SASS, the instruction set of the GPU, which differs between architectures. A fat binary is NVIDIA’s own container around such images.
The files are made and read with NVIDIA’s tools. nvcc writes them with
-cubin and -fatbin, and takes .ptx and
.cubin files as input. cuobjdump accepts cubin files and host
binaries, dumps their SASS, ELF sections and PTX, and lists and extracts the embedded
files. nvdisasm disassembles standalone cubin files.
nvcc -cubin -arch=sm_80 kernel.cu -o kernel.cubin
cuobjdump -sass kernel.cubin
nvdisasm kernel.cubin
Not described
Known, not yet covered
- Reference: this overview is the only page. The ELF header and the section list of a cubin, the sections NVIDIA adds (code, constant and shared-memory data, relocations, debug information) and the architecture field in the header are not described. NVIDIA’s CUDA Binary Utilities documentation shows the output of its tools for them.
- Reference: the SASS instruction set of each GPU generation is not described, and neither are the options of
cuobjdumpandnvdisasm. - Viewer: there is no viewer for these formats yet. A cubin is not shown as ELF sections, and a fat binary is not unpacked.
Unknown
- Reference: the layout of the
.fatbincontainer (its header, the entries and how each image is stored or compressed) is not described in the NVIDIA pages these pages draw on. It would have to be worked out from real files or from open-source tools that read it. - Reference: the bit-level encoding of SASS instructions is not described in those pages either.
Links
Software
- CUDA Toolkit – NVIDIA’s
nvcc,cuobjdumpandnvdisasm(Windows, Linux)
Reference
- CUDA Binary Utilities – NVIDIA’s guide to cubin files,
cuobjdumpandnvdisasm - NVCC compiler driver – NVIDIA’s guide, with the
.cubinand.fatbinfile suffixes and options