Hello, I am using CUDA.jl package for svd calculation. But I get automatic casting to Array{Float32,2}.
Could anyone help please ? Below, I share m.w.e.
using CUDA
A = CUDA.rand(10, 20) ; # getting float32 on GPU
# then applying SVD on it
F = CUDA.svd(A) # Object F has U, S, V and Vt
# everything is still on GPU
1 ./ F.S # returns CuArray
# then applying some operations
diagm(1 ./ F.S) # returns Array{Float32,2} not CuArray{Float32,2}
# trying another approach
CUDA.diagm(1 ./ F.S) # again returns Array{Float32,2} not CuArray{Float32,2}
Hi Kadir, if you’re using PLUTO, you need to define CUDA: GPUArrays, such as:
begin
using CUDA
using CUDA: GPUArrays
CUDA.allowscalar(false) # without this fallback functionality performing iteration
end
begin
B = CUDA.rand(10, 20) ; # getting float32 on GPU
# then applying SVD on it
F = CUDA.svd(Array(B)) # Object F has U, S, V and Vt
# everything is still on GPU
1 ./ F.S # returns CuArray
# then applying some operations
diagm(1 ./ F.S) # returns Array{Float32,2} not CuArray{Float32,2}
# trying another approach
CUDA.diagm(1 ./ F.S) # again returns Array{Float32,2} not CuArray{Float32,2}
end