NVIDIA CUDA Toolkit 12.4 Enhances Runtime Fatbin Creation

NVIDIA CUDA Toolkit 12.4 Enhances Runtime Fatbin Creation

The NVIDIA CUDA Toolkit 12.4 has introduced a significant enhancement to its GPU programming suite with the addition of the nvFatbin library. This new library allows for the creation of fatbins—containers for multiple versions of code—at runtime, a feature that greatly simplifies the dynamic generation of these binaries, according to NVIDIA Technical Blog.

New Library Offers Runtime Fatbin Creation Support

Fatbins, or NVIDIA device code fat binaries, are essential for storing different architectures’ code, such as sm_61 and sm_90. Previously, generating a fatbin required using the command line tool fatbinary, which was not conducive to dynamic code generation. This process involved writing generated code to a file, calling fatbinary through exec, and handling the outputs, making it cumbersome and inefficient.

The nvFatbin library streamlines this process by enabling the programmatic creation of fatbins without the need for file operations or command line parsing. This development significantly reduces the complexity of dynamically generating fatbins, making it an invaluable tool for developers working with NVIDIA GPUs.

How to Get Runtime Fatbin Creation Working

Creating a fatbin at runtime using the nvFatbin library involves several steps. First, a handle is created to reference the relevant pieces of device code:

nvFatbinCreate(&handle, numOptions, options);

Next, the device code is added to the fatbin using functions specific to the type of input, such as CUBIN, PTX, or LTO-IR:

nvFatbinAddCubin(handle, data, size, arch, name);
nvFatbinAddPTX(handle, data, size, arch, name, ptxOptions);
nvFatbinAddLTOIR(handle, data, size, arch, name, ltoirOptions);

The resultant fatbin is then retrieved after allocating a buffer to ensure sufficient space:

nvFatbinSize(linker, &fatbinSize);
void* fatbin = malloc(fatbinSize);
nvFatbinGet(handle, fatbin);

Finally, the handle is cleaned up:


Offline Fatbin Generation with NVCC

For offline fatbin generation, developers can use the NVCC compiler with the -fatbin option. This method allows for the creation of fatbins containing multiple entries for different architectures, ensuring compatibility across various GPU models.

Compatibility and Benefits

The nvFatbin library guarantees compatibility with CUDA inputs from the same major version or lower. This means that a fatbin created with nvFatbin from CUDA Toolkit 12.4 will work with code generated by any CUDA Toolkit 12.X or earlier but is not guaranteed to work with future versions like CUDA Toolkit 13.0.

This compatibility ensures that developers can confidently use nvFatbin to manage their GPU code without worrying about future incompatibilities. Additionally, the nvFatbin library supports inputs from previous versions of the CUDA toolkit, further enhancing its utility.

The Bigger Picture

The introduction of nvFatbin completes the suite of runtime compiler components, including nvPTXCompiler, NVRTC, and nvJitLink. These tools interact seamlessly, allowing developers to compile, link, and generate fatbins dynamically, ensuring optimal performance and compatibility across different GPU architectures.


The nvFatbin library in CUDA Toolkit 12.4 marks a significant advancement in GPU programming, simplifying the creation of flexible and compatible fatbins at runtime. This enhancement not only streamlines the development process but also ensures that code remains optimized and compatible for future GPU architectures, making it an essential tool for developers working with NVIDIA GPUs.

Image source: Shutterstock

Source link

Related Articles

Do you run a company that want to build a new website and are looking for a web agency in Sweden that can do the job? At Partna you can get connected to experienced web agencies that are interested in helping you with your website development. Partna is an online service where you simply post your web development needs in order to get business offers from skilled web agencies in Sweden. Instead of reaching out to hundreds of agencies by yourself, let up to 5 web agencies come to you via Partna.
Back to top button