# CUDA.device() info is displayed, but neither printed nor stored on variable

**URL:** <https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330>\
**Category:** New to Julia\
**Tags:** cuda\
**Created:** [August 25, 2022, 2:48pm UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330 "2022-08-25T14:48:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cirobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cirobr/32/219994_2.png) [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Post date:** [August 25, 2022, 2:48pm UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330/1 "2022-08-25T14:48:55Z")

</div>

Cheers,  
The below command in my Julia 1.6.7 / CUDA v3.12.0 system:

> CUDA.device()

has the answer:

> CuDevice(0): NVIDIA GeForce RTX 2060

However, when printing or storing the output on a variable,

> println( CUDA.device() )  
> x = CUDA.device()

the displayed answer is just:

> CuDevice(0)

Would appreciate any support, as to obtain full answer. Thanks.

---

<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:** [August 25, 2022, 7:43pm UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330/2 "2022-08-25T19:43:14Z")

</div>

The REPL prints things differently, the same applies to e.g. array objects. You can use the `display` function if you want REPL-style output from a script.

---

<div class="post-metadata">

**Author:** ![cirobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cirobr/32/219994_2.png) [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Post date:** [August 26, 2022, 1:34pm UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330/3 "2022-08-26T13:34:14Z")

</div>

For printing, OK. For storing the info on a variable, or on a data frame (which is the actual application), the variable apparently retains only the short form. Thus, we loose the information.

Is there a way to get GPU info from within Julia, without loosing such info?

Thanks.

---

<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:** [August 29, 2022, 7:53am UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330/4 "2022-08-29T07:53:04Z")

</div>

That seems like a weird thing to do. Why don’t you query the name directly (`CUDA.name(::CuDevice)`) instead of relying on the I/O routines?

---

<div class="post-metadata">

**Author:** ![cirobr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cirobr/32/219994_2.png) [@cirobr](https://discourse.julialang.org/u/cirobr)\
**Post date:** [August 29, 2022, 7:05pm UTC](https://discourse.julialang.org/t/cuda-device-info-is-displayed-but-neither-printed-nor-stored-on-variable/86330/5 "2022-08-29T19:05:56Z")

</div>

That works, thanks.
