# Differential Equations Solve - top not defined

When running

using DifferentialEquations
f(u,p,t) = 1.01*u
u0 = 1/2
tspan = (0.0,1.0)
prob = ODEProblem(f,u0,tspan)
sol = solve(prob, Tsit5(), reltol=1e-8, abstol=1e-8)

As taken off the DifferentialEquations.jl Documentation, I get:

ERROR: LoadError: UndefVarError: top not defined
Stacktrace:
[1] solve!(::OrdinaryDiffEq.ODEIntegrator{Tsit5,false,Float64,Nothing,Float64,DiffEqBase.NullParameters,Float64,Float64,Float64,Array{Float64,1},ODESolution{Float64,1,Array{Float64,1},Nothing,Nothing,Array{Float64,1},Array{Array{Float64,1},1},ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem},Tsit5,OrdinaryDiffEq.InterpolationData{ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Array{Float64,1},Array{Float64,1},Array{Array{Float64,1},1},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64}},DiffEqBase.DEStats},ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},OrdinaryDiffEq.Tsit5ConstantCache{Float64,Float64},OrdinaryDiffEq.DEOptions{Float64,Float64,Float64,Float64,typeof(DiffEqBase.ODE_DEFAULT_NORM),typeof(LinearAlgebra.opnorm),CallbackSet{Tuple{},Tuple{}},typeof(DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN),typeof(DiffEqBase.ODE_DEFAULT_PROG_MESSAGE),typeof(DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK),DataStructures.BinaryHeap{Float64,DataStructures.LessThan},DataStructures.BinaryHeap{Float64,DataStructures.LessThan},Nothing,Nothing,Int64,Tuple{},Tuple{},Tuple{}},Float64,Float64,Nothing,OrdinaryDiffEq.DefaultInit}) at /home/tobiasharvey/.julia/packages/OrdinaryDiffEq/yn1YB/src/solve.jl:421
[2] #__solve#382 at /home/tobiasharvey/.julia/packages/OrdinaryDiffEq/yn1YB/src/solve.jl:5 [inlined]
[3] solve_call(::ODEProblem{Float64,Tuple{Float64,Float64},false,DiffEqBase.NullParameters,ODEFunction{false,typeof(f),LinearAlgebra.UniformScaling{Bool},Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing,Nothing},Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}},DiffEqBase.StandardODEProblem}, ::Tsit5; merge_callbacks::Bool, kwargs::Base.Iterators.Pairs{Symbol,Float64,Tuple{Symbol,Symbol},NamedTuple{(:reltol, :abstol),Tuple{Float64,Float64}}}) at /home/tobiasharvey/.julia/packages/DiffEqBase/T5smF/src/solve.jl:92
[4] #solve_up#461 at /home/tobiasharvey/.julia/packages/DiffEqBase/T5smF/src/solve.jl:114 [inlined]
[5] #solve#460 at /home/tobiasharvey/.julia/packages/DiffEqBase/T5smF/src/solve.jl:102 [inlined]
[6] top-level scope at /home/tobiasharvey/Desktop/sbpwaveprop/test.jl:6
[7] include(::String) at ./client.jl:457
[8] top-level scope at REPL[2]:1
in expression starting at /home/tobiasharvey/Desktop/sbpwaveprop/test.jl:6

Looking at my pkg status I have:

Status ~/.julia/environments/v1.5/Project.toml
[0c46a032] DifferentialEquations v6.15.0
[1dea7af3] OrdinaryDiffEq v5.42.1

What is going here? There are no warning messages or anything only this crash.

I canât reproduce. Whatâs your full ]st -m?

Just went ahead and deleted everything julia related on my computer, and reinstalledâŚnow it works. Not sure what was upâŚnot really a solution, but I guess id call this âclosedâ.

Having the same problem after installing v1.5.1 and running code. I have deleted the compiled cache folder but did not help. What exatly did you delete/reinstall?

What happens if you do ]add DataStructures@0.18?

Then it works.

When you did that, what packages decreased their versions? Theyâre the ones to blame and we need to go talk to their authors.

1 Like

The issue on your setup is due to Queryverse blocking DataStructures v0.18 through TextParse in https://github.com/queryverse/TextParse.jl/pull/159 . I alerted the author and it should all get updated soon enough. Why this is an issue is a weird deep thing but hopefully it all blows over soon! Sorry about that but thanks for helping pinpoint where it is.

2 Likes

Thank you for taking care of it in no time!

Im getting the same error.
(first time using julia)
i have tried using https://github.com/MikeInnes/zygote-paper but got error with 1.5.1 so i tried downgrading to 1.3 and got error again (different kind of errors from error in prepocessing to âtop not definedâ) now im using 1.3.2 and i tried running a very simple example from the documentation (with using Flux, DiffEqFlux, DifferentialEquations, Plots) and got error again âtop not definedâ at âODEProblemâ

i tried also updating and nothing seems to work.
if someone could at least suggest me a possible solution (either a version of julia that isnt full of bugs or a combination of flux+ DiffEqFlux ecc.) it would be nice

What exactly did you run? Did you ]add DataStructures@0.18? Everything should be fine on a standard installation if a package doesnât hold that back.

i manged to fix it by reinstalling 1.5.1 again.

please update the âusing CuArrayâ here: https://diffeqflux.sciml.ai/dev/GPUs/
probably before i tried following one of these outdated tutorials (adding CuArray instead of CUDA) which downgraded other pkgs
i have tried using CUDA instead of CuArray but now im getting ArgumentError: cannot take the CPU address of a CuArray{Float32,1} (in DiffEqFlux.sciml_train)

also im getting an error here https://diffeqflux.sciml.ai/dev/examples/mnist_neural_ode/
Error evaluating MNISTodeClassification.jl
LoadError: MethodError: no method matching eachcol(::Array{Float32,4})
also:
LoadError: MethodError: no method matching loss(::Array{CuArray,1})
Closest candidates are:
loss(::Any, ::Any)
i have checked on github the MNISTodeClassification has not been updated in 16 monthsâŚ

i checked the wrong the github repo.

tried it again and im getting only error at loss
but i think its due to the code itself since loss(x, y) is there

i still get the same error in the ode/gpu example though

gpu(prob_neuralode(u0,p))
âŚ
pred = predict_neuralodeÂ§
âŚ
result_neuralode = DiffEqFlux.sciml_train(loss_neuralode, p,
maxiters = 300) ArgumentError: cannot take the CPU address of a CuArray{Float32,1}

(im only copy-pasting and it should be fine without gpu)

https://github.com/SciML/DiffEqFlux.jl/pull/398 should fix this. Probably something changed in the way the DataLoader expects the data to be fed.

I am getting the same top not defined error when trying the example ODE problem. Following the thread, I think I have tracked down the source to an older version of DataStructures (v0.17.20), which was being held back this time by BinaryBuilder.

@ChrisRackauckas - Thanks for your previous posts, they helped me find track down the problem very quickly.

Yeah sorry about this whole DataStructures change: it was a PITA but itâs mostly passed now. The actual reason it became a huge issue is that DataStructures accidentally didnât have a deprecation warning, as in it has a deprecation and some dispatches but not the ones we used, so two years later the dispatches we use were deleted and so there was this version gap without a middleground , but actually the transition versions did exist for a long time but we never got the warning. Good times @oxinabox . Moral of the story is, there is a version set of DiffEq+DataStructures that hiccups when it doesnât exactly resolve everything but that should be relatively in the past now.

3 Likes

Hi, thanks for the previous replies on this issue. Could you also have a look of my issue please? thanks in advance.

I have the same problem when using DifferetialEquations and Flux. I am getting warning of top is deprecated, use first instead. Iâve checked, it is a function inside OrdinaryDiffEq.jl, and then the training broke after one iteration with error âtype BinaryHeap has no field comparerâ. I actually have reported this issue perviously on github and it was solved aftering I did ]add DataStructures@0.18. But now the same error occurs.

Now my package status looks like this and I am pretty struggling at the moment. Is it anything wrong with package versions? Thank you very much.