# Getting GPU info

**URL:** <https://discourse.julialang.org/t/getting-gpu-info/30913>\
**Category:** GPU\
**Created:** [November 10, 2019, 10:28am UTC](https://discourse.julialang.org/t/getting-gpu-info/30913 "2019-11-10T10:28:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [November 10, 2019, 10:28am UTC](https://discourse.julialang.org/t/getting-gpu-info/30913/1 "2019-11-10T10:28:02Z")

</div>

Hi folks,  
I’m kinda starting with all this CUDA stuff, and am working with different GPUs on different computers (home, work, etc…). I’m building my first kernels, and one of the things that I need to know is the size of the grids, blocks and threads my GPUs have available. Can I get that information from within my Julia code?  
Best,  
Ferran.

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 10, 2019, 12:58pm UTC](https://discourse.julialang.org/t/getting-gpu-info/30913/2 "2019-11-10T12:58:54Z")

</div>

Yes, you can use CUDAdrv.jl for that which exposes the CUDA driver api. For example: [https://github.com/JuliaGPU/CUDAnative.jl/blob/d654cba72ce3b44d4bb33dcd5651638947eae7cc/examples/pairwise.jl#L92](https://github.com/JuliaGPU/CUDAnative.jl/blob/d654cba72ce3b44d4bb33dcd5651638947eae7cc/examples/pairwise.jl#L92)  
Easier though is to use to occupancy API to just let you know how many thread/blocks to use (check the above file on the master branch).

---

<div class="post-metadata">

**Author:** ![Ferran\_Mazzanti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ferran_mazzanti/32/7458_2.png) [@Ferran\_Mazzanti](https://discourse.julialang.org/u/Ferran_Mazzanti)\
**Post date:** [November 10, 2019, 5:23pm UTC](https://discourse.julialang.org/t/getting-gpu-info/30913/3 "2019-11-10T17:23:15Z")

</div>

AH, I see… in that way I get the number of threads I can use. What about the max number of blocks and grids I can have?  
Thanks again,  
Ferran.

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 10, 2019, 9:03pm UTC](https://discourse.julialang.org/t/getting-gpu-info/30913/4 "2019-11-10T21:03:07Z")

</div>

Check out the CUDA documentation (or grep the CUDAdrv.jl source code); these enumerations come from there: [CUDA Driver API :: CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/cuda-driver-api/group __CUDA__ TYPES.html)

---

<div class="post-metadata">

**Author:** ![bpsomu](https://avatars.discourse-cdn.com/v4/letter/b/ee7513/32.png) [@bpsomu](https://discourse.julialang.org/u/bpsomu)\
**Post date:** [April 24, 2025, 11:41am UTC](https://discourse.julialang.org/t/getting-gpu-info/30913/5 "2025-04-24T11:41:40Z")

</div>

Use CUDA.jl and try the following:

`device = CUDA.device()`

`sm_count = CUDA.attribute(device, CUDA.DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT)`
