nvfatbin#

Note#

The nvfatbin bindings are not supported on nvFatbin installations <12.4. Ensure the installed CUDA toolkit’s nvFatbin version is >=12.4.

The Tile IR API (cuda.bindings.nvfatbin.add_tile_ir()) is only available in CUDA 13.1+.

Functions#

NvFatbin defines the following functions for creating and populating fatbinaries.

cuda.bindings.nvfatbin.create(options, size_t options_count) intptr_t#

nvFatbinCreate creates a new handle.

Parameters:
  • options (object) –

    An array of strings, each containing a single option. It can be:

    • an int as the pointer address to the nested sequence, or

    • a Python sequence of ints, each of which is a pointer address to a valid sequence of ‘char’, or

    • a nested Python sequence of str.

  • options_count (size_t) – Number of options.

Returns:

Address of nvFatbin handle.

Return type:

intptr_t

See also

nvFatbinCreate

cuda.bindings.nvfatbin.destroy(intptr_t handle)#

nvFatbinDestroy frees the memory associated with the given handle.

Parameters:

handle (intptr_t) – nvFatbin handle.

See also

nvFatbinDestroy

cuda.bindings.nvfatbin.add_ptx(
intptr_t handle,
code,
size_t size,
arch,
identifier,
options_cmd_line,
)#

nvFatbinAddPTX adds PTX to the fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • code (bytes) – The PTX code.

  • size (size_t) – The size of the PTX code.

  • arch (str) – The numerical architecture that this PTX is for (the XX of any sm_XX, lto_XX, or compute_XX).

  • identifier (str) – Name of the PTX, useful when extracting the fatbin with tools like cuobjdump.

  • options_cmd_line (str) – Options used during JIT compilation.

See also

nvFatbinAddPTX

cuda.bindings.nvfatbin.add_cubin(intptr_t handle, code, size_t size, arch, identifier)#

nvFatbinAddCubin adds a CUDA binary to the fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • code (bytes) – The cubin.

  • size (size_t) – The size of the cubin.

  • arch (str) – The numerical architecture that this cubin is for (the XX of any sm_XX, lto_XX, or compute_XX).

  • identifier (str) – Name of the cubin, useful when extracting the fatbin with tools like cuobjdump.

See also

nvFatbinAddCubin

cuda.bindings.nvfatbin.add_ltoir(
intptr_t handle,
code,
size_t size,
arch,
identifier,
options_cmd_line,
)#

nvFatbinAddLTOIR adds LTOIR to the fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • code (bytes) – The LTOIR code.

  • size (size_t) – The size of the LTOIR code.

  • arch (str) – The numerical architecture that this LTOIR is for (the XX of any sm_XX, lto_XX, or compute_XX).

  • identifier (str) – Name of the LTOIR, useful when extracting the fatbin with tools like cuobjdump.

  • options_cmd_line (str) – Options used during JIT compilation.

See also

nvFatbinAddLTOIR

cuda.bindings.nvfatbin.add_reloc(intptr_t handle, code, size_t size)#

nvFatbinAddReloc adds relocatable PTX entries from a host object to the fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • code (bytes) – The host object image.

  • size (size_t) – The size of the host object image code.

See also

nvFatbinAddReloc

cuda.bindings.nvfatbin.add_tile_ir(
intptr_t handle,
code,
size_t size,
identifier,
options_cmd_line,
)#

nvFatbinAddTileIR adds Tile IR to the fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • code (bytes) – The Tile IR.

  • size (size_t) – The size of the Tile IR.

  • identifier (str) – Name of the Tile IR, useful when extracting the fatbin with tools like cuobjdump.

  • options_cmd_line (str) – Options used during JIT compilation.

See also

nvFatbinAddTileIR

cuda.bindings.nvfatbin.size(intptr_t handle) size_t#

nvFatbinSize returns the fatbinary’s size.

Parameters:

handle (intptr_t) – nvFatbin handle.

Returns:

The fatbinary’s size.

Return type:

size_t

See also

nvFatbinSize

cuda.bindings.nvfatbin.get(intptr_t handle, buffer)#

nvFatbinGet returns the completed fatbinary.

Parameters:
  • handle (intptr_t) – nvFatbin handle.

  • buffer (bytes) – memory to store fatbinary.

See also

nvFatbinGet

cuda.bindings.nvfatbin.get_error_string(int result) str#

nvFatbinGetErrorString returns an error description string for each error code.

Parameters:

result (Result) – error code.

See also

nvFatbinGetErrorString

cuda.bindings.nvfatbin.version() tuple#

nvFatbinVersion returns the current version of nvFatbin.

Returns:

  • unsigned int: The major version.

  • unsigned int: The minor version.

Return type:

A 2-tuple containing

See also

nvFatbinVersion

Types#

class cuda.bindings.nvfatbin.Result(value: int)#

The enumerated type nvFatbinResult defines API call result codes. nvFatbin APIs return nvFatbinResult codes to indicate the result.

See nvFatbinResult.

SUCCESS = <Result.SUCCESS: 0>#
ERROR_INTERNAL = <Result.ERROR_INTERNAL: 1>#
ERROR_ELF_ARCH_MISMATCH = <Result.ERROR_ELF_ARCH_MISMATCH: 2>#
ERROR_ELF_SIZE_MISMATCH = <Result.ERROR_ELF_SIZE_MISMATCH: 3>#
ERROR_MISSING_PTX_VERSION = <Result.ERROR_MISSING_PTX_VERSION: 4>#
ERROR_NULL_POINTER = <Result.ERROR_NULL_POINTER: 5>#
ERROR_COMPRESSION_FAILED = <Result.ERROR_COMPRESSION_FAILED: 6>#
ERROR_COMPRESSED_SIZE_EXCEEDED = <Result.ERROR_COMPRESSED_SIZE_EXCEEDED: 7>#
ERROR_UNRECOGNIZED_OPTION = <Result.ERROR_UNRECOGNIZED_OPTION: 8>#
ERROR_INVALID_ARCH = <Result.ERROR_INVALID_ARCH: 9>#
ERROR_INVALID_NVVM = <Result.ERROR_INVALID_NVVM: 10>#
ERROR_EMPTY_INPUT = <Result.ERROR_EMPTY_INPUT: 11>#
ERROR_MISSING_PTX_ARCH = <Result.ERROR_MISSING_PTX_ARCH: 12>#
ERROR_PTX_ARCH_MISMATCH = <Result.ERROR_PTX_ARCH_MISMATCH: 13>#
ERROR_MISSING_FATBIN = <Result.ERROR_MISSING_FATBIN: 14>#
ERROR_INVALID_INDEX = <Result.ERROR_INVALID_INDEX: 15>#
ERROR_IDENTIFIER_REUSE = <Result.ERROR_IDENTIFIER_REUSE: 16>#
ERROR_INTERNAL_PTX_OPTION = <Result.ERROR_INTERNAL_PTX_OPTION: 17>#