Hi,
I’m quite new to Julia computing and even more to GPU computing but I notice that selectdim function from julia output is stored on the CPU acording to this error: “ERROR: ArgumentError: cannot take the CPU address of a CuArray{Float32,2,Nothing}” when running this MWE:
a = CuArrays.rand(3,5)
a*selectdim(a,1,1)
ERROR: ArgumentError: cannot take the CPU address of a CuArray{Float32,2,Nothing}
Stacktrace:
[1] unsafe_convert(::Type{Ptr{Float32}}, ::CuArray{Float32,2,Nothing}) at C:\Users\geoff\.juliapro\JuliaPro_v1.3.1-2\packages\CuArrays\e8PLr\src\array.jl:226
[2] gemv!(::Char, ::Bool, ::CuArray{Float32,2,Nothing}, ::SubArray{Float32,1,CuArray{Float32,2,Nothing},Tuple{Int64,Base.Slice{Base.OneTo{Int64}}},true}, ::Bool, ::CuArray{Float32,1,Nothing}) at C:\Users\julia\AppData\Local\Julia-1.3.1\share\julia\stdlib\v1.3\LinearAlgebra\src\blas.jl:587
[3] gemv!(::CuArray{Float32,1,Nothing}, ::Char, ::CuArray{Float32,2,Nothing}, ::SubArray{Float32,1,CuArray{Float32,2,Nothing},Tuple{Int64,Base.Slice{Base.OneTo{Int64}}},true}, ::Bool, ::Bool) at C:\Users\julia\AppData\Local\Julia-1.3.1\share\julia\stdlib\v1.3\LinearAlgebra\src\matmul.jl:463
[4] mul! at C:\Users\julia\AppData\Local\Julia-1.3.1\share\julia\stdlib\v1.3\LinearAlgebra\src\matmul.jl:66 [inlined]
[5] mul! at C:\Users\julia\AppData\Local\Julia-1.3.1\share\julia\stdlib\v1.3\LinearAlgebra\src\matmul.jl:203 [inlined]
[6] *(::CuArray{Float32,2,Nothing}, ::SubArray{Float32,1,CuArray{Float32,2,Nothing},Tuple{Int64,Base.Slice{Base.OneTo{Int64}}},true}) at C:\Users\julia\AppData\Local\Julia-1.3.1\share\julia\stdlib\v1.3\LinearAlgebra\src\matmul.jl:47
[7] top-level scope at none:0
Has I understand I need to transfert the output of selectdim to GPU as this work:
a*CuArray(selectdim(a,1,1))
But I want this part of my code to work on CPU when a is on CPU and to work on GPU otherwise, is this possible ?
Thanks in advance for your help,
Geoffrey