Closed TheStarAlight closed 1 year ago
OMG, just forgot the dt argument, added the dt and the solver ran successfully.
So to sum up (dt should always be assigned) |
adaptive=true | adaptive=false | |
---|---|---|---|
save_everystep=true | err (not supported) | ✔ | |
save_everystep=false | ✔ | ✔ |
But here comes another problem, I try to adjust the ratio of load to CPU (using the default EnsembleGPUKernel()
which is actually EnsembleGPUKernel(0.2)
), but every trial failed. Only EnsembleGPUKernel(0.0)
passed with no err.
julia> CUDA.@time sol = solve(monteprob, GPUTsit5(), EnsembleGPUKernel(0.2), trajectories=trajNum, adaptive=false, save_everystep=false, dt=0.1)
ERROR: TaskFailedException
Stacktrace:
[1] wait
@ .\task.jl:334 [inlined]
[2] __solve(ensembleprob::EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, alg::GPUTsit5, ensemblealg::EnsembleGPUKernel; trajectories::Int64, batch_size::Int64, unstable_check::Function, adaptive::Bool, kwargs::Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}})
@ DiffEqGPU C:\Users\ZMY\.julia\packages\DiffEqGPU\EdiL9\src\DiffEqGPU.jl:235
[3] #solve#35
@ C:\Users\ZMY\.julia\packages\DiffEqBase\72SnT\src\solve.jl:818 [inlined]
[4] macro expansion
@ C:\Users\ZMY\.julia\packages\CUDA\DfvRa\src\utilities.jl:25 [inlined]
[5] top-level scope
@ C:\Users\ZMY\.julia\packages\CUDA\DfvRa\src\pool.jl:490 [inlined]
[6] top-level scope
@ .\REPL[11]:0
[7] top-level scope
@ C:\Users\ZMY\.julia\packages\CUDA\DfvRa\src\initialization.jl:52
nested task error: TaskFailedException
Stacktrace:
[1] wait
@ .\task.jl:334 [inlined]
[2] threading_run(func::Function)
@ Base.Threads .\threadingconstructs.jl:38
[3] macro expansion
@ .\threadingconstructs.jl:97 [inlined]
[4] tmap(f::Function, args::UnitRange{Int64})
@ SciMLBase C:\Users\ZMY\.julia\packages\SciMLBase\cheTp\src\ensemble\basic_ensemble_solve.jl:173
[5] #solve_batch#505
@ C:\Users\ZMY\.julia\packages\SciMLBase\cheTp\src\ensemble\basic_ensemble_solve.jl:164 [inlined]
[6] f
@ C:\Users\ZMY\.julia\packages\DiffEqGPU\EdiL9\src\DiffEqGPU.jl:221 [inlined]
[7] macro expansion
@ C:\Users\ZMY\.julia\packages\DiffEqGPU\EdiL9\src\DiffEqGPU.jl:226 [inlined]
[8] (::DiffEqGPU.var"#8#14"{DiffEqGPU.var"#f#13"{Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}}, EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, SimpleDiffEq.GPUSimpleTsit5, UnitRange{Int64}}})()
@ DiffEqGPU .\task.jl:123
nested task error: MethodError: no method matching solve(::ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, ::SimpleDiffEq.GPUSimpleTsit5; save_everystep=false, dt=0.1)
Closest candidates are:
solve(::ODEProblem, ::SimpleDiffEq.GPUSimpleTsit5; dt) at C:\Users\ZMY\.julia\packages\SimpleDiffEq\vIpeG\src\tsit5\gpuatsit5.jl:9 got unsupported keyword argument "save_everystep"
solve(::SciMLBase.AbstractDEProblem, ::Any...; sensealg, u0, p, kwargs...) at C:\Users\ZMY\.julia\packages\DiffEqBase\72SnT\src\solve.jl:765
solve(::Any...; kwargs...) at C:\Users\ZMY\.julia\packages\CommonSolve\TGRvG\src\CommonSolve.jl:23
...
Stacktrace:
[1] kwerr(::NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}, ::Function, ::ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, ::SimpleDiffEq.GPUSimpleTsit5)
@ Base .\error.jl:163
[2] batch_func(i::Int64, prob::EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, alg::SimpleDiffEq.GPUSimpleTsit5; kwargs::Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}})
@ SciMLBase C:\Users\ZMY\.julia\packages\SciMLBase\cheTp\src\ensemble\basic_ensemble_solve.jl:92
[3] (::SciMLBase.var"#507#509"{Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}}, EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, SimpleDiffEq.GPUSimpleTsit5})(i::Int64)
@ SciMLBase C:\Users\ZMY\.julia\packages\SciMLBase\cheTp\src\ensemble\basic_ensemble_solve.jl:165
[4] macro expansion
@ C:\Users\ZMY\.julia\packages\SciMLBase\cheTp\src\ensemble\basic_ensemble_solve.jl:174 [inlined]
[5] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}}, EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, SimpleDiffEq.GPUSimpleTsit5}, Tuple{UnitRange{Int64}}, Vector{Union{}}, UnitRange{Int64}})(onethread::Bool)
@ SciMLBase .\threadingconstructs.jl:85
[6] (::SciMLBase.var"#400#threadsfor_fun#510"{SciMLBase.var"#507#509"{Base.Pairs{Symbol, Real, Tuple{Symbol, Symbol}, NamedTuple{(:save_everystep, :dt), Tuple{Bool, Float64}}}, EnsembleProblem{ODEProblem{SVector{3, Float64}, Tuple{Float64, Float64}, false, SVector{3, Float64}, ODEFunction{false, typeof(lorenz), LinearAlgebra.UniformScaling{Bool}, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, typeof(SciMLBase.DEFAULT_OBSERVED), Nothing, Nothing}, Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}, SciMLBase.StandardODEProblem}, var"#1#2", typeof(SciMLBase.DEFAULT_OUTPUT_FUNC), typeof(SciMLBase.DEFAULT_REDUCTION), Nothing}, SimpleDiffEq.GPUSimpleTsit5}, Tuple{UnitRange{Int64}}, Vector{Union{}}, UnitRange{Int64}})()
@ SciMLBase .\threadingconstructs.jl:52
It seems that the program throws exceptions only when EnsembleGPUKernel(x≠0)
, so I guess it might be raised by missing of dispatch, there's no appropriate method solving GPUTsit5 on CPU which accepts the save_everystep
arg. I refered to SimpleDiffEq\vIpeG\src\tsit5\gpuatsit5.jl
and found the non-adaptive version solve()
doesn't support the argument as expected.
The above case is for non-adaptive case (adaptive=false
). In SimpleDiffEq\vIpeG\src\tsit5\gpuatsit5.jl
the adaptive version solve()
has the kwarg save_everystep
, however, some other kinds of err are thrown... Is the function unprepared for use?
SimpleDiffEq was the initial version of the now matured OrdinaryDiffEq.jl. Hence, it was not adequately maintained. When using the CPU version, the new solvers dispatches to SimpleDiffEq.jl to provide a reasonable performance estimate compared to the GPU ones. I'll fix things.
And yes, you'll need to provide the initial dt
.
Just a heads up, usage Float32
is preferred with GPU. https://cuda.juliagpu.org/stable/tutorials/introduction/#A-simple-example-on-the-CPU
Thanks for your advice! I know GPU is better at single float computing than in double, but in my recent program which solves a quantum-mechanic wave equation, the program didn't give a satisfactory result unless I switch to double float, it seems in QM simulation you must use double float. I have given up the idea since then.😂 Anyway, many thanks.
@utkarsh530 was this handle?
Yes, need to tag SimpleDiffEq.jl
.
Tagged.
I'm very glad to see the update of v1.18 :D However, solver parameter support seems incomplete, and I just encountered this problem. Still using the lorentz example:
Compared with my former successful attempt where
adaptive=true, save_everystep=false
are not assigned, this time an error is thrown: