Identifying Nvidia GPUs

Nvidia provides a very useful utility called nvidia-smi for GPU identification. It implies that when called as nvidia-smi -q it will print everything it can. But I fail to spot the compute capability in that output. If I try:

nvidia-smi --query-gpu=compute_cap

then it does report the compute capability.

If you do not like what it does, you can always write your own. So herewith one example. It is partially based on Nvidia's example deviceQuery.cpp in the Samples/1_Utilities directory of its CUDA samples repository, but reduced from C++ to C and with NVML added.

ident.c (or original ident1.c)

$ curl -O www.mjr19.org.uk/IT/nv/ident.c
$ gcc -o ident ident.c -lcuda -lnvidia-ml -lcudart
$ ./ident
GTX 1650: 4 GB (192GB/s) 896 cores@1.62GHz cc=75 (Turing) PCI 8 GB/s
$ ./ident -v
GTX 1650: 4 GB (192GB/s) 896 cores@1.62GHz cc=75 (Turing) PCI 8 GB/s
Mem: 128 bits 6.0GHz no ECC
L2 cache: 1MB
GPU: 14 SMs, guessed 64 cores per SM, max boost 2.1GHz, current 1.70GHz
Max shared memory per SM: 64KB
PCIe v3x16 (7.8 GB/s)
Max power: 75W

$ ./ident 
RTX 3060: 12 GB (360GB/s) 3584 cores@1.84GHz cc=86 (Ampere) PCI 16 GB/s

$ ./ident
RTX 5060 Ti: 16 GB (448GB/s) 4608 cores@2.60GHz cc=120 (Blackwell) PCI 16 GB/s

I failed to find functions for returning the GPU's generational name (Turing, Ampere, Blackwell, etc), or for the number of cores per SM. So this version has some hard-coded tables, which deal with most things up to Blackwell...

The PCI speeds listed are the maximums possible in the current host. The card may be capable of better in a different host.