How to query gpu's codename?

We know every generation NVIDIA gpu has a codename, such as ada,turing,ampere, so is there any api or method that I can use to query it?

Hi @pango99,

sorry for the late reply. You could use nvidia-smi -q which will show Product Architecture:

nvidia-smi.exe -q

==============NVSMI LOG==============

Timestamp                                 : Wed May 10 16:29:46 2023
Driver Version                            : 531.29
CUDA Version                              : 12.1

Attached GPUs                             : 1
GPU 00000000:0A:00.0
    Product Name                          : NVIDIA GeForce RTX 3080
    Product Brand                         : GeForce
    Product Architecture                  : Ampere
    Display Mode                          : Enabled
    Display Active                        : Enabled
    Persistence Mode                      : N/A
    MIG Mode
        Current                           : N/A
        Pending                           : N/A
    Accounting Mode                       : Disabled

Otherwise you could use CUDA and cudaProps::name through cudaGetDeviceProperties to find the GPU name and use a look-up table to find the architecture.
See also the CUDA samples for more details.