# Copy with CuArrays and \`allowscalar(false)\`

**URL:** <https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341>\
**Category:** New to Julia\
**Tags:** gpu\
**Created:** [July 12, 2018, 7:36pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341 "2018-07-12T19:36:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [July 12, 2018, 7:36pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/1 "2018-07-12T19:36:48Z")

</div>

Hi,

I am using `CuArrays` but the following operation seems unsupported:

```julia
using CuArrays
x=rand(10) |> cu;
CuArrays.allowscalar(false)
V[:,1] .= x;

```

It gives:

`ERROR: scalar getindex is disabled`

Using `copy!` from [link](https://github.com/JuliaGPU/CuArrays.jl/blob/7d13934e9c47f2b15a83c399d610e0bc5a4ddc3d/src/gpuarray_interface.jl#L95) is troublesome because a `CuArray` does not have `ptr` in its struct.

Is there a way around?

Thank you for your help.

---

<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:** [July 13, 2018, 12:33pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/2 "2018-07-13T12:33:41Z")

</div>

> [@rveltz](#):
>
> Using `copy!` from [link](https://github.com/JuliaGPU/CuArrays.jl/blob/7d13934e9c47f2b15a83c399d610e0bc5a4ddc3d/src/gpuarray_interface.jl#L95) is troublesome because a `CuArray` does not have `ptr` in its struct.

That’s a bug, it should use the `buf` field. Probably not covered by the tests.

---

<div class="post-metadata">

**Author:** ![rveltz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rveltz/32/2707_2.png) [@rveltz](https://discourse.julialang.org/u/rveltz)\
**Post date:** [July 17, 2018, 6:17am UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/3 "2018-07-17T06:17:47Z")

</div>

Should I open an issue in CuArrays?

---

<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:** [July 17, 2018, 2:35pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/4 "2018-07-17T14:35:05Z")

</div>

> [@rveltz](#):
>
> Should I open an issue in CuArrays?

Yeah. Adapting the code should be pretty easy though, just look at the preceding functions. I can have a look in a couple of days, better open an issue not to lose track though.

---

<div class="post-metadata">

**Author:** ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)\
**Post date:** [December 11, 2019, 2:18pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/5 "2019-12-11T14:18:10Z")

</div>

@rveltz, @maleadt I just run into the same problem when trying to prepare some high-level CuArrays example code. Has this been solved already meanwhile (I had to downgrade the CUDA packages due to some issues, so I don’t know if it is fixed in the newest versions)? Could you put here the link to the corresponding issue?

---

<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:** [December 11, 2019, 2:50pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/6 "2019-12-11T14:50:35Z")

</div>

Your issue is probably not related to this one, which has been fixed. Please open a bug report with the specific invocation that triggers scalar iteration.

---

<div class="post-metadata">

**Author:** ![samo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samo/32/35398_2.png) [@samo](https://discourse.julialang.org/u/samo)\
**Post date:** [December 11, 2019, 6:08pm UTC](https://discourse.julialang.org/t/copy-with-cuarrays-and-allowscalar-false/12341/7 "2019-12-11T18:08:17Z")

</div>

@maleadt: you are absolutely right; it is a different issue. I created a bug report:  
[https://github.com/JuliaGPU/CuArrays.jl/issues/534](https://github.com/JuliaGPU/CuArrays.jl/issues/534)
