1 unstable release

0.1.0 Dec 29, 2023

#140 in #cuda

Apache-2.0

17KB
277 lines

This repo contains parsers for CUDA binary files. These file formats are not publicly documented so correctly parsing them can be tricky.

What are CUDA binaries?

These are the GPU executable files generated from compiling CUDA code. They are often embedded within other applications. Among other things, they contain the instructions that are actually executed on GPU.

You may have interacted with these files if you've used any of the cuModuleLoad* functions in the CUDA driver API.

There are two types of CUDA binaries:

  • cubin files: These run on one particular GPU architecture. This is because each architecture can have different instruction sets and capabilities
  • fatbin files: These are fat binaries that contain cubin files for several architectures

This repo has well tested support for parsing cubin files and basic support for parsing fatbin files. See below for more details

The parsers are implemented in Rust, but can be exposed to other languages if there's interest (feel free to create an issue!).

Why?

cubin files contain a lot of useful information that's not exposed by CUDA APIs.

The parsers in this repo were initially built for an internal project that needed detailed information about CUDA modules and kernels.

How can you confidently parse an undocumented format?

This post contains a detailed answer: https://blog.vivekpanyam.com/parsing-an-undocumented-file-format

Short version: we test on thousands of cubin files to ensure that the output produced by this parser matches the output of cuobjdump from NVIDIA.

Dependencies

~6MB
~127K SLoC