# Why does this not work in Flux?

**URL:** <https://discourse.julialang.org/t/why-does-this-not-work-in-flux/93689>\
**Category:** New to Julia\
**Created:** [January 28, 2023, 1:16pm UTC](https://discourse.julialang.org/t/why-does-this-not-work-in-flux/93689 "2023-01-28T13:16:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahmed\_Salih](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ahmed_salih/32/206579_2.png) [@Ahmed\_Salih](https://discourse.julialang.org/u/Ahmed_Salih)\
**Post date:** [January 28, 2023, 1:16pm UTC](https://discourse.julialang.org/t/why-does-this-not-work-in-flux/93689/1 "2023-01-28T13:16:53Z")

</div>

Hello!

New to the Flux library.

I went through their documentian and understand how it works for arrays of one dimension. I am trying to use it on GPU. The code I use is:

```julia
using Flux, CUDA, StaticArrays

T = Float32
NL = 10^6

src = CuArray(rand(SVector{3,T},NL))
idx = CuArray(rand(1:6195, NL))
dst = CuArray(zeros(SVector{3,T}, NL))
NNlib.scatter!(+, dst, src, idx)

```

Which returns the error:

```julia
ERROR: InvalidIRError: compiling kernel #scatter_kernel!(typeof(+), CuDeviceVector{SVector{3, Float32}, 1}, CuDeviceVector{SVector{3, Float32}, 1}, CuDeviceVector{Int64, 1}) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to atomic_cas!)

```

I’ve tested the CPU version and it works great - how come it breaks here?

Kind regards
