Search code examples
gcccudanvcc

Finding compute and sm numbers in a binary file


I have a binary file compiled with cuda enabled features and gcc. I want to know which cuda architectures are included in the binary file?

I mean sm and compute compatibility numbers which are -gencode arch=compute_XX,code=sm_XX.


Solution

  • NVIDIA ship binary utilites which can display headers and disassemble the binary payloads in object files, libraries, and executables. cudaobjdump can be used as follows:

    $ nvcc -arch=sm_62 -std=c++11 -I ./ main.cu -o main
    $ cuobjdump ./main
    
    Fatbin elf code:
    ================
    arch = sm_62
    code version = [1,7]
    producer = <unknown>
    host = linux
    compile_size = 64bit
    
    Fatbin elf code:
    ================
    arch = sm_62
    code version = [1,7]
    producer = cuda
    host = linux
    compile_size = 64bit
    
    Fatbin ptx code:
    ================
    arch = sm_62
    code version = [5,0]
    producer = cuda
    host = linux
    compile_size = 64bit
    compressed
    

    Which shows both the binary and PTX payloads included in the executable.