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.
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.
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
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.
Related reading
- How can I implement a custom `RNN` specifically an ESN in Tensorflow?
- How can I implement dilated convolution in keras?
- How can I know whether a tensorflow tensor is in cuda or cpu?
- How can I list all Tensorflow variables a node depends on?
- How can I get the return value of a function passed to multiprocessing.Process?
- How can I get the source code of a Python function?
- How can I make a trainable parameter in keras?
- How can I make tensorflow run on a GPU with capability 2.x?
System design interview problems on this topic
- Design an LLM Inference Service: solution and walkthrough
- Design a GPU Cluster Scheduler for ML Training: solution and walkthrough
- Design ChatGPT: solution and walkthrough
- Design an E-commerce Recommendation System: solution and walkthrough
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo 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 courseML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.