LinearSolve.jl icon indicating copy to clipboard operation
LinearSolve.jl copied to clipboard

LinearSolve + Krylove + CUDA

Open ASLabadi opened this issue 11 months ago • 4 comments

Hi guys, i understood from the documentation that I can use LinearSolve with Krylov in both CPU and GPU. i am trying to solve a sparse linear system Ax=b as the following:

Pl_cpu = ilu(A_cpu) # the preconditioner prob_cpu = LinearProblem(A_cpu, b_cpu) sol = solve(prob_cpu, KrylovJL_MINRES(rtol=1e-8),Pl =Pl_cpu, maxiters =200, verbose = true, log = true);

This version works super fine.

But when I try to perform it on the GPU, I convert A, b to CuSparseMatrixCSC.

P_gpul=ilu02(A_gpu) prob_gpu=LinearProblem(A_gpu, b_gpu) sol = solve(prob_gpu, KrylovJL_MINRES(rtol=1e-8),Pl =Pl_gpu, maxiters =200, verbose = true, log = true);

I get an error:

ERROR: MethodError: no method matching ldiv!(::CuSparseMatrixCSR{Float64, Int32}, ::CuArray{Float64, 1, CUDA.Mem.DeviceBuffer})

Closest candidates are: ldiv!(::AbstractVecOrMat, ::AbstractVecOrMat, ::SciMLOperators.AbstractSciMLOperator)
@ SciMLOperators C:\Users\ahmad.julia\packages\SciMLOperators\M8FAe\src\left.jl:27
ldiv!(::Any, ::Sparspak.SpkSparseSolver.SparseSolver{IT, FT}, ::Any) where {IT, FT}
@ Sparspak C:\Users\ahmad.julia\packages\Sparspak\oqBYl\src\SparseCSCInterface\SparseCSCInterface.jl:263 ldiv!(::Any, ::ChainRulesCore.AbstractThunk) @ ChainRulesCore C:\Users\ahmad.julia\packages\ChainRulesCore\0t04l\src\tangent_types\thunks.jl:95 ...

ASLabadi avatar Jul 11 '23 15:07 ASLabadi