# This example in CUDA.jl does not work for me?

**URL:** <https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294>\
**Category:** GPU\
**Created:** [February 8, 2023, 6:57pm UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294 "2023-02-08T18:57:17Z")\
**Posts on this page:** 6\
**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:** [February 8, 2023, 6:57pm UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/1 "2023-02-08T18:57:17Z")

</div>

[https://cuda.juliagpu.org/stable/api/kernel/#Element-access-and-broadcasting](https://cuda.juliagpu.org/stable/api/kernel/#Element-access-and-broadcasting)

```julia
using Test

using CUDA

a = rand(Float16, (16, 16))
b = rand(Float16, (16, 16))
c = rand(Float32, (16, 16))

a_dev = CuArray(a)
b_dev = CuArray(b)
c_dev = CuArray(c)
d_dev = similar(c_dev)

function kernel(a_dev, b_dev, c_dev, d_dev)
    conf = WMMA.Config{16, 16, 16, Float32}

    a_frag = WMMA.load_a(pointer(a_dev), 16, WMMA.ColMajor, conf)
    b_frag = WMMA.load_b(pointer(b_dev), 16, WMMA.ColMajor, conf)
    c_frag = WMMA.load_c(pointer(c_dev), 16, WMMA.ColMajor, conf)

    c_frag = 0.5f0 .* c_frag

    d_frag = WMMA.mma(a_frag, b_frag, c_frag, conf)

    WMMA.store_d(pointer(d_dev), d_frag, 16, WMMA.ColMajor, conf)

    return
end

@cuda threads=32 kernel(a_dev, b_dev, c_dev, d_dev)
d = Array(d_dev)

@test all(isapprox.(a * b + 0.5 * c, d; rtol=0.01))

```

Produces the error:

```julia
ERROR: LLVM error: Cannot select: intrinsic %llvm.nvvm.wmma.m16n16k16.store.d.col.stride.f32

```

Any one knows the solution

Kind regards

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [February 9, 2023, 6:05am UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/2 "2023-02-09T06:05:04Z")

</div>

Which Julia version are you using? My guess is that you likely need to upgrade to get a newer LLVM.

---

<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:** [February 9, 2023, 8:26am UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/3 "2023-02-09T08:26:10Z")

</div>

Works here on 1.8.

---

<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:** [February 9, 2023, 9:06am UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/4 "2023-02-09T09:06:03Z")

</div>

I gave it a shot on 1.8.0 yesterday. Will try again from a clean terminal and if it still does not work I will try updating to latest 1.8.x

Kind regards

---

<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:** [February 9, 2023, 3:56pm UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/5 "2023-02-09T15:56:22Z")

</div>

Also make sure you’re using Julia as downloaded from the homepage or juliaup, other sources (e.g., your Linux distro) are not supported.

---

<div class="post-metadata">

**Author:** ![Phil\_Tomson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/phil_tomson/32/3575_2.png) [@Phil\_Tomson](https://discourse.julialang.org/u/Phil_Tomson)\
**Post date:** [February 17, 2023, 11:23pm UTC](https://discourse.julialang.org/t/this-example-in-cuda-jl-does-not-work-for-me/94294/6 "2023-02-17T23:23:12Z")

</div>

I’m getting the same error with Julia 1.8.3.

> julia\> CUDA.versioninfo()  
> CUDA toolkit 11.7, artifact installation  
> NVIDIA driver 470.161.3, for CUDA 11.4  
> CUDA driver 11.4
> 
> Libraries:
> 
> - CUBLAS: 11.10.1
> - CURAND: 10.2.10
> - CUFFT: 10.7.2
> - CUSOLVER: 11.3.5
> - CUSPARSE: 11.7.3
> - CUPTI: 17.0.0
> - NVML: 11.0.0+470.161.3
> - CUDNN: 8.30.2 (for CUDA 11.5.0)
> - CUTENSOR: 1.4.0 (for CUDA 11.5.0)
> 
> Toolchain:
> 
> - Julia: 1.8.3
> - LLVM: 13.0.1
> - PTX ISA support: 3.2, 4.0, 4.1, 4.2, 4.3, 5.0, 6.0, 6.1, 6.3, 6.4, 6.5, 7.0, 7.1, 7.2
> - Device capability support: sm\_35, sm\_37, sm\_50, sm\_52, sm\_53, sm\_60, sm\_61, sm\_62, sm\_70, sm\_72, sm\_75, sm\_80, sm\_86
> 
> 1 device:  
> 0: NVIDIA GeForce GTX 1070 (sm\_61, 6.201 GiB / 7.921 GiB available)
