# CUDA.jl finds CUDA installation but cannot execute any commands

**URL:** <https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368>\
**Category:** GPU\
**Created:** [June 4, 2021, 12:04am UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368 "2021-06-04T00:04:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![crinders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crinders/32/8434_2.png) [@crinders](https://discourse.julialang.org/u/crinders)\
**Post date:** [June 4, 2021, 12:04am UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368/1 "2021-06-04T00:04:18Z")

</div>

I have installed CUDA.jl . I have checked with `JULIA_DEBUG=CUDA` and `CUDA.version()` that indeed the local CUDA install is being used. But to my chagrin, not even the most simple code works:

```julia
julia> using CUDA
julia> CUDA.version()
v"11.0.0"

julia> CUDA.functional(true)
true

julia> a = CuArray{Int}(undef, 1024);
julia> b = copy(a);
julia> fill!(b, 0)
ERROR: cfunction: closures are not supported on this platform
Stacktrace:
  [1] compile_method_instance(job::GPUCompiler.CompilerJob, method_instance::Core.MethodInstance)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/eJOtJ/src/jlgen.jl:325
  [2] macro expansion
    @ ~/.julia/packages/TimerOutputs/PZq45/src/TimerOutput.jl:226 [inlined]
  [3] irgen(job::GPUCompiler.CompilerJob, method_instance::Core.MethodInstance)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/eJOtJ/src/irgen.jl:4
  [4] macro expansion
    @ ~/.julia/packages/GPUCompiler/eJOtJ/src/driver.jl:142 [inlined]
  [5] macro expansion
    @ ~/.julia/packages/TimerOutputs/PZq45/src/TimerOutput.jl:226 [inlined]
  [6] macro expansion
    @ ~/.julia/packages/GPUCompiler/eJOtJ/src/driver.jl:141 [inlined]
  [7] emit_llvm(job::GPUCompiler.CompilerJob, method_instance::Any, world::UInt64; libraries::Bool, deferred_codegen::Bool, optimize::Bool, only_entry::Bool)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/eJOtJ/src/utils.jl:62
  [8] emit_llvm(job::GPUCompiler.CompilerJob, method_instance::Any, world::UInt64)
    @ GPUCompiler ~/.julia/packages/GPUCompiler/eJOtJ/src/utils.jl:60
  [9] cufunction_compile(job::GPUCompiler.CompilerJob)
    @ CUDA ~/.julia/packages/CUDA/3VnCC/src/compiler/execution.jl:300
 [10] check_cache
    @ ~/.julia/packages/GPUCompiler/eJOtJ/src/cache.jl:47 [inlined]
 [11] cached_compilation
    @ ~/.julia/packages/GPUArrays/Z5nPF/src/host/construction.jl:6 [inlined]
 [12] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob{GPUCompiler.PTXCompilerTarget, CUDA.CUDACompilerParams, GPUCompiler.FunctionSpec{GPUArrays.var"#4#5", Tuple{CUDA.CuKernelContext, CuDeviceVector{Int64, 1}, Int64}}}, compiler::typeof(CUDA.cufunction_compile), linker::typeof(CUDA.cufunction_link))
    @ GPUCompiler ~/.julia/packages/GPUCompiler/eJOtJ/src/cache.jl:0
 [13] cufunction(f::GPUArrays.var"#4#5", tt::Type{Tuple{CUDA.CuKernelContext, CuDeviceVector{Int64, 1}, Int64}}; name::Nothing, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ CUDA ~/.julia/packages/CUDA/3VnCC/src/compiler/execution.jl:289
 [14] cufunction
    @ ~/.julia/packages/CUDA/3VnCC/src/compiler/execution.jl:283 [inlined]
 [15] macro expansion
    @ ~/.julia/packages/CUDA/3VnCC/src/compiler/execution.jl:102 [inlined]
 [16] #launch_heuristic#286
    @ ~/.julia/packages/CUDA/3VnCC/src/gpuarrays.jl:17 [inlined]
 [17] launch_heuristic
    @ ~/.julia/packages/CUDA/3VnCC/src/gpuarrays.jl:17 [inlined]
 [18] gpu_call(::GPUArrays.var"#4#5", ::CuArray{Int64, 1}, ::Int64; target::CuArray{Int64, 1}, total_threads::Nothing, threads::Nothing, blocks::Nothing, name::Nothing)
    @ GPUArrays ~/.julia/packages/GPUArrays/Z5nPF/src/device/execution.jl:61
 [19] gpu_call
    @ ~/.julia/packages/GPUArrays/Z5nPF/src/device/execution.jl:46 [inlined]
 [20] fill!(A::CuArray{Int64, 1}, x::Int64)
    @ GPUArrays ~/.julia/packages/GPUArrays/Z5nPF/src/host/construction.jl:5
 [21] top-level scope
    @ REPL[14]:1
 [22] top-level scope
    @ ~/.julia/packages/CUDA/3VnCC/src/initialization.jl:81

```

Or

```julia
julia> cu(rand(5)) .* cu(rand(5))
[same error]

```

But,

```julia
julia> cu(rand(5,5))*cu(rand(5))
5-element CuArray{Float32, 1}:
 1.8394606
 1.5616181
 1.4858192
 1.0533601
 1.7902193

```

My main problem, though, is that I can’t use a Flux model with the GPU.  
Any idea how I can correct this behavior?

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [June 4, 2021, 3:45am UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368/2 "2021-06-04T03:45:51Z")

</div>

I don’t have anything better to suggest apart from sometimes I think

`]build CUDA` can fix the issues.

My CUDA version is 11.3 and the code works fo me. So yeah, that might be it as well.

---

<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:** [June 4, 2021, 6:18am UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368/3 "2021-06-04T06:18:21Z")

</div>

> [@xiaodai](#):
>
> `]build CUDA` can fix the issues.

That command doesn’t do anything anymore.

@crinders you’re running into a known issue because of a ‘bug’ in Julia. We have a workaround in [Workaround cfunction closures on non-x86 by jpsamaroo · Pull Request #191 · JuliaGPU/GPUCompiler.jl · GitHub](https://github.com/JuliaGPU/GPUCompiler.jl/pull/191), I’ll finish that up and get it merged. If you then want to try CUDA.jl out, use GPUCompiler.jl/GPUArrays.jl/CUDA.jl from master (or wait for a new version, probably some time next week).

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [June 4, 2021, 6:23am UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368/4 "2021-06-04T06:23:00Z")

</div>

> [@maleadt](#):
>
> That command doesn’t do anything anymore.

good to know

---

<div class="post-metadata">

**Author:** ![crinders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crinders/32/8434_2.png) [@crinders](https://discourse.julialang.org/u/crinders)\
**Post date:** [June 4, 2021, 1:21pm UTC](https://discourse.julialang.org/t/cuda-jl-finds-cuda-installation-but-cannot-execute-any-commands/62368/5 "2021-06-04T13:21:29Z")

</div>

Thanks! I’ll try that as soon as it gets merged.

Too bad it wasn’t something simple :-!
