CUDA cores
GPU programming
Python
Numba
GPU detection

How can I get the number of CUDA cores in my GPU using Python and Numba?

ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design

Introduction

Numba can tell you a lot about the current CUDA device, but it does not expose a direct universal property named "CUDA core count." The usual approach is to query the GPU’s compute capability and multiprocessor count, then multiply the number of streaming multiprocessors by the architecture-specific number of cores per multiprocessor.

What Numba Can Read Directly

Numba’s CUDA device object exposes properties such as name, compute capability, and multiprocessor count. Those are the ingredients you need.

python
1from numba import cuda
2
3
4def get_device_info():
5    device = cuda.get_current_device()
6    print("name:", device.name)
7    print("compute capability:", device.compute_capability)
8    print("multiprocessors:", device.MULTIPROCESSOR_COUNT)
9
10
11get_device_info()

This does not yet print the total CUDA core count, but it gives you the data required to estimate it.

Why There Is No Single Direct Number

The number of CUDA cores per multiprocessor depends on the GPU architecture. One architecture generation may have a different cores-per-SM ratio than another.

That means the formula is not simply "ask the driver for cores." It is usually:

  • Read compute capability.
  • Map that architecture to cores per streaming multiprocessor.
  • Multiply by MULTIPROCESSOR_COUNT.

A Practical Python Helper

python
1from numba import cuda
2
3CORES_PER_SM = {
4    (5, 0): 128,
5    (5, 2): 128,
6    (5, 3): 128,
7    (6, 0): 64,
8    (6, 1): 128,
9    (6, 2): 128,
10    (7, 0): 64,
11    (7, 2): 64,
12    (7, 5): 64,
13    (8, 0): 64,
14    (8, 6): 128,
15    (8, 9): 128,
16}
17
18
19def estimate_cuda_cores() -> int:
20    device = cuda.get_current_device()
21    capability = device.compute_capability
22    sms = device.MULTIPROCESSOR_COUNT
23
24    if capability not in CORES_PER_SM:
25        raise ValueError(f"Unknown compute capability: {capability}")
26
27    return sms * CORES_PER_SM[capability]
28
29
30print("estimated CUDA cores:", estimate_cuda_cores())

This is an estimate based on published architecture rules, which is usually what people mean when they ask for CUDA core count programmatically.

What This Number Does And Does Not Mean

CUDA core count is only one hardware characteristic. It does not tell you everything about GPU performance. Clock speed, memory bandwidth, tensor cores, cache layout, and occupancy all matter too.

That is why two GPUs with similar core counts can still behave very differently on real workloads.

For kernel tuning, the more immediately useful Numba properties are often compute capability, warp size, maximum threads per block, and shared memory limits rather than just total core count.

If the compute capability is missing from your lookup table, the safest next step is to check the GPU architecture in vendor documentation and update the mapping deliberately. Guessing the cores-per-SM value can produce a believable but wrong result, which is worse than explicitly reporting that the architecture is unknown.

That is also why many tooling scripts report compute capability and multiprocessor count alongside the estimated core total. Those raw properties are directly observed from the device, while the final core count depends on an external architecture table that may need maintenance as new GPUs appear.

Common Pitfalls

One common mistake is assuming Numba has a built-in CUDA_CORES property. It generally does not; you infer the number from architecture data.

Another mistake is using an incomplete mapping table and treating the result as universally correct. New GPU generations may require updated cores-per-SM values.

A third issue is overvaluing the CUDA core count itself. It is helpful for rough hardware comparison, but not a substitute for benchmarking your actual kernels.

Summary

  • Numba can report compute capability and multiprocessor count, but not a universal direct CUDA core count property.
  • The usual method is to map compute capability to cores per SM and multiply by the SM count.
  • Treat the result as an architecture-based estimate, not the full story of GPU performance.
  • For optimization work, benchmark real kernels and inspect more than just total core count.

Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Basis Lab
No course covers this one yet

Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.

Build my course
ML System Design practice on Codemia

Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.

Practice ML system design