# CUDAKernels not defined error in KernelAbstractions example

**URL:** <https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003>\
**Category:** New to Julia\
**Tags:** question, gpu, cuda, kernelabstractions, cudajl\
**Created:** [March 13, 2023, 1:07pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003 "2023-03-13T13:07:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![prikmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/prikmm/32/47530_2.png) [@prikmm](https://discourse.julialang.org/u/prikmm)\
**Post date:** [March 13, 2023, 1:07pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/1 "2023-03-13T13:07:43Z")

</div>

Hi all,

I am new to Julia and am currently trying to run `performant_matmul.jl` example present in `KernelsAbstractions.jl`. I have added `CUDA.jl` to my environment which I created using activate & instantiate using the `Project.toml` present in KA’s directory. I keep getting `CUDAKernels not defined` error.

This might be a stupid mistake but am not able to pinpoint the issue. Can someone help me in understanding why this is breaking?

PS: Eveything works if I don’t add CUDA.jl into the environment i.e everything works on CPU.

ENVIRONMENT:  
Windows 11, 16GB RAM, 1TB SSD, Ryzen 7 with Radeon Graphics, RTX 3060 6GB RAM.

Detailed steps:

- Create a Julia env using `Project.toml` in `KernelAbstractions.jl` directory

```julia
1. cd KA-src
2. julia
3. ]
4. activate .
5. instantiate
6. add CUDA
8. exit julia terminal

```

- compile the `performant_matmul.jl` script using the below given command after .

```julia
julia --project=${KA_SOURCE_PATH} .\examples\performant_matmul.jl

```

Error:

```julia
ERROR: LoadError: UndefVarError: CUDAKernels not defined
Stacktrace:
 [1] top-level scope
   @ C:\Users\priyam\julia-work\ka-src\examples\utils.jl:4
 [2] include(fname::String)
   @ Base.MainInclude .\client.jl:476
 [3] top-level scope
   @ C:\Users\priyam\julia-work\ka-src\examples\performant_matmul.jl:5
in expression starting at C:\Users\priyam\julia-work\ka-src\examples\utils.jl:2
in expression starting at C:\Users\priyam\julia-work\ka-src\examples\performant_matmul.jl:5

```

---

<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:** [March 13, 2023, 1:42pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/2 "2023-03-13T13:42:39Z")

</div>

I assume you’re using the KA.jl main branch, which depends on [Move CUDAKernels to CUDA.jl by vchuravy · Pull Request #1772 · JuliaGPU/CUDA.jl · GitHub](https://github.com/JuliaGPU/CUDA.jl/pull/1772)

---

<div class="post-metadata">

**Author:** ![prikmm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/prikmm/32/47530_2.png) [@prikmm](https://discourse.julialang.org/u/prikmm)\
**Post date:** [March 13, 2023, 2:37pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/3 "2023-03-13T14:37:58Z")

</div>

@maleadt Thanks! It worked.

---

<div class="post-metadata">

**Author:** ![weymouth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/weymouth/32/15839_2.png) [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Post date:** [March 21, 2023, 2:27pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/4 "2023-03-21T14:27:42Z")

</div>

Can you be a little more explicit on what we need to do to get the main branch of KA working? I tried to

`] add CUDA.jl#1772`

But the package manager wasn’t happy with this.

---

<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:** [March 21, 2023, 2:46pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/5 "2023-03-21T14:46:32Z")

</div>

Try `] add CUDA.jl#vc/ka_transition` – you need to specify the branch, not the PR number.  
In any case, it’s not recommended to use the KA.jl master branch unless you have a very good reason to, especially during a transition like this.

---

<div class="post-metadata">

**Author:** ![weymouth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/weymouth/32/15839_2.png) [@weymouth](https://discourse.julialang.org/u/weymouth)\
**Post date:** [March 21, 2023, 4:28pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/6 "2023-03-21T16:28:39Z")

</div>

Thanks - that worked.

So what is the recommendation for using KA at the moment?

---

<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:** [March 21, 2023, 7:21pm UTC](https://discourse.julialang.org/t/cudakernels-not-defined-error-in-kernelabstractions-example/96003/7 "2023-03-21T19:21:37Z")

</div>

> [@weymouth](#):
>
> So what is the recommendation for using KA at the moment?

What’s wrong with the released version?
