# Are there any way to copy a Dict or a custom datatype which contains an Array to GPU by CUDA?

**URL:** <https://discourse.julialang.org/t/are-there-any-way-to-copy-a-dict-or-a-custom-datatype-which-contains-an-array-to-gpu-by-cuda/50217>\
**Category:** GPU\
**Tags:** question\
**Created:** [November 16, 2020, 8:56am UTC](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-dict-or-a-custom-datatype-which-contains-an-array-to-gpu-by-cuda/50217 "2020-11-16T08:56:58Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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 16, 2020, 10:11am UTC](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-dict-or-a-custom-datatype-which-contains-an-array-to-gpu-by-cuda/50217/4 "2020-11-16T10:11:20Z")

</div>

You didn’t mention wrapping that struct in an array as well. That’s currently not supported by `CuArray`. You can work around it by eagerly converting the `CuArray`s to `CuDeviceArray` (which are `isbits`) using `cudaconvert` and storing those in a `CuArray`, see e.g. [Passing array of pointers to CUDA kernel](https://discourse.julialang.org/t/passing-array-of-pointers-to-cuda-kernel/33570). But to `cudaconvert` your `TestType` here you’ll need to make it parametric (`a::T`, `b::T`, `T<:AbstractArray`) and add Adapt.jl rules (`Adapt.adapt_structure(to, x::TestType) = TestType(adapt(to, x,a), ...)`), as I mentioned above.

---

_[View the full topic](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-dict-or-a-custom-datatype-which-contains-an-array-to-gpu-by-cuda/50217)._
