I am also getting the same error when I try to solve a linear ODE
(of type [dx/dt] = [Jacobian].[ x ]) with a huge number of simultaneous equations ~1million equations. My problem is highly stiff, so I use CVODE_BDF from sundials (the jacobian is also sparse in my problem).
Now to accelerate this process I opted for GPU. Here is a minimum working code for the same. ( This is the same as example from DiffEqGPU package: Getting Started with GPU-Accelerated Differential Equations in Julia · DiffEqGPU.jl). But I want to use CVODE_BDF or QNDFwith CUDA (because my problem is huge and stiff also these solvers work best for my problem) . @SantiagoMorandi ,@ChrisRackauckas , Is there any way we could leverage GPU acceleration for solvers such as CVODE_BDF or QNDF? Kindly guide.
using DifferentialEquations, CUDA, LinearAlgebra
using Sundials, Krylov, LinearSolve
u0 = cu(rand(1000))
A = cu(randn(1000, 1000))
f(du, u, p, t) = mul!(du, A, u)
prob = ODEProblem(f, u0, (0.0f0, 1.0f0)) # Float32 is better on GPUs!
sol =solve(prob, Tsit5()); # this works
sol = solve(prob, QNDF(linsolve= KrylovJL_GMRES())) # doesnt work
sol = solve(prob, CVODE_BDF((linear_solver= :GMRES)) # doesnt work
Error- Stacktrace
ERROR: MethodError: no method matching Sundials.NVector(::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer})
Closest candidates are:
Sundials.NVector(::Vector{Float64})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\nvector_wrapper.jl:16
Sundials.NVector(::Ptr{Sundials._generic_N_Vector})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\nvector_wrapper.jl:24
Stacktrace:
[1] __init(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…}, ks::Vector{…}; verbose::Bool, callback::Nothing, abstol::Float64, reltol::Float64, saveat::Vector{…}, d_discontinuities::Vector{…}, tstops::Vector{…}, maxiters::Int64, dt::Nothing, dtmin::Float64, dtmax::Float64, timeseries_errors::Bool, dense_errors::Bool, save_everystep::Bool, save_idxs::Nothing, save_on::Bool, save_start::Bool, save_end::Bool, dense::Bool, progress::Bool, progress_steps::Int64, progress_name::String, progress_message::typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE), progress_id::Symbol, save_timeseries::Nothing, advance_to_tstop::Bool, stop_at_next_tstop::Bool, userdata::Nothing, alias_u0::Bool, kwargs::@Kwargs{})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:200
[2] __init(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…}, ks::Vector{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:78
[3] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…}, ks::Vector{…}, recompile::Type{…}; calculate_error::Bool, kwargs::@Kwargs{})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:15
[4] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…}, ks::Vector{…}, recompile::Type{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:3
[5] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…}, ks::Vector{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:3
[6] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…}, ts::Vector{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:3
[7] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…}, timeseries::Vector{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:3
[8] __solve(prob::ODEProblem{…}, alg::CVODE_BDF{…})
@ Sundials C:\Users\Balaji\.julia\packages\Sundials\vGumE\src\common_interface\solve.jl:3
[9] solve_call(_prob::ODEProblem{…}, args::CVODE_BDF{…}; merge_callbacks::Bool, kwargshandle::KeywordArgError, kwargs::@Kwargs{})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:559
[10] solve_call(_prob::ODEProblem{…}, args::CVODE_BDF{…})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:529
[11] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::CuArray{…}, p::SciMLBase.NullParameters, args::CVODE_BDF{…}; kwargs::@Kwargs{})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:1020
[12] solve_up(prob::ODEProblem{…}, sensealg::Nothing, u0::CuArray{…}, p::SciMLBase.NullParameters, args::CVODE_BDF{…})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:993
[13] solve(prob::ODEProblem{…}, args::CVODE_BDF{…}; sensealg::Nothing, u0::Nothing, p::Nothing, wrap::Val{…}, kwargs::@Kwargs{})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:930
[14] solve(prob::ODEProblem{…}, args::CVODE_BDF{…})
@ DiffEqBase C:\Users\Balaji\.julia\packages\DiffEqBase\s433k\src\solve.jl:920
[15] top-level scope
@ REPL[10]:1
[16] top-level scope
@ C:\Users\Balaji\.julia\packages\CUDA\rXson\src\initialization.jl:208
Some type information was truncated. Use `show(err)` to see complete types.