# Differential Equations Solve - top not defined

**URL:** <https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510>\
**Category:** General Usage\
**Tags:** question, package, diffeq\
**Created:** [August 7, 2020, 4:12pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510 "2020-08-07T16:12:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![totorotoby](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@totorotoby](https://discourse.julialang.org/u/totorotoby)\
**Post date:** [August 7, 2020, 4:12pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/1 "2020-08-07T16:12:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 7, 2020, 8:52pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/2 "2020-08-07T20:52:47Z")

</div>

I can’t reproduce. What’s your full `]st -m`?

---

<div class="post-metadata">

**Author:** ![totorotoby](https://avatars.discourse-cdn.com/v4/letter/t/779978/32.png) [@totorotoby](https://discourse.julialang.org/u/totorotoby)\
**Post date:** [August 8, 2020, 1:28am UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/3 "2020-08-08T01:28:54Z")

</div>

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”.

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [August 31, 2020, 12:09pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/4 "2020-08-31T12:09:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 31, 2020, 1:16pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/5 "2020-08-31T13:16:27Z")

</div>

What happens if you do `]add DataStructures@0.18`?

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [August 31, 2020, 1:29pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/6 "2020-08-31T13:29:01Z")

</div>

Then it works.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 31, 2020, 1:50pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/7 "2020-08-31T13:50:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [August 31, 2020, 2:03pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/8 "2020-08-31T14:03:01Z")

</div>

![grafik](https://global.discourse-cdn.com/julialang/original/3X/b/b/bbd733345eccb92b84932500a313ec4b86e72aeb.png)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [August 31, 2020, 3:55pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/9 "2020-08-31T15:55:44Z")

</div>

The issue on your setup is due to Queryverse blocking DataStructures v0.18 through TextParse in [https://github.com/queryverse/TextParse.jl/pull/159](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.

---

<div class="post-metadata">

**Author:** ![moesphere](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moesphere/32/3348_2.png) [@moesphere](https://discourse.julialang.org/u/moesphere)\
**Post date:** [September 1, 2020, 6:22am UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/10 "2020-09-01T06:22:34Z")

</div>

Thank you for taking care of it in no time!

---

<div class="post-metadata">

**Author:** ![lorrp1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorrp1/32/17647_2.png) [@lorrp1](https://discourse.julialang.org/u/lorrp1)\
**Post date:** [September 1, 2020, 4:00pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/11 "2020-09-01T16:00:41Z")

</div>

Im getting the same error.  
(first time using julia)  
i have tried using [https://github.com/MikeInnes/zygote-paper](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

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 1, 2020, 5:25pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/12 "2020-09-01T17:25:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lorrp1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorrp1/32/17647_2.png) [@lorrp1](https://discourse.julialang.org/u/lorrp1)\
**Post date:** [September 2, 2020, 7:59pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/13 "2020-09-02T19:59:21Z")

</div>

i manged to fix it by reinstalling 1.5.1 again.

please update the “using CuArray” here: [https://diffeqflux.sciml.ai/dev/GPUs/](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 [GPU-based MNIST Neural ODE Classifier · DiffEqFlux.jl](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…

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 2, 2020, 8:02pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/14 "2020-09-02T20:02:43Z")

</div>

Thanks. Done [https://github.com/SciML/DiffEqFlux.jl/commit/4b49eace0b3b1f5d17b4c9a656712c5883fbcf82](https://github.com/SciML/DiffEqFlux.jl/commit/4b49eace0b3b1f5d17b4c9a656712c5883fbcf82)

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [September 2, 2020, 8:03pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/15 "2020-09-02T20:03:06Z")

</div>

> [@lorrp1](#):
>
> also im getting an error here [https://diffeqflux.sciml.ai/dev/examples/mnist\_neural\_ode/](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…

@avikpal do you know about this one?

---

<div class="post-metadata">

**Author:** ![lorrp1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lorrp1/32/17647_2.png) [@lorrp1](https://discourse.julialang.org/u/lorrp1)\
**Post date:** [September 2, 2020, 8:22pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/16 "2020-09-02T20:22:09Z")

</div>

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(p)  
…  
result\_neuralode = DiffEqFlux.sciml\_train(loss\_neuralode, p,  
ADAM(0.05), cb = callback,  
maxiters = 300) **ArgumentError: cannot take the CPU address of a CuArray{Float32,1}**

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

---

<div class="post-metadata">

**Author:** ![avikpal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/avikpal/32/6550_2.png) [@avikpal](https://discourse.julialang.org/u/avikpal)\
**Post date:** [September 3, 2020, 5:46am UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/17 "2020-09-03T05:46:08Z")

</div>

[https://github.com/SciML/DiffEqFlux.jl/pull/398](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.

---

<div class="post-metadata">

**Author:** ![mihalybaci](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mihalybaci/32/13528_2.png) [@mihalybaci](https://discourse.julialang.org/u/mihalybaci)\
**Post date:** [October 20, 2020, 6:03pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/18 "2020-10-20T18:03:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [October 20, 2020, 6:46pm UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/19 "2020-10-20T18:46:23Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ayaoyao214](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ayaoyao214/32/19370_2.png) [@ayaoyao214](https://discourse.julialang.org/u/ayaoyao214)\
**Post date:** [November 17, 2020, 2:47am UTC](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510/20 "2020-11-17T02:47:59Z")

</div>

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.  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/1/f/1fdc869f9117666d0fcc39aa98f8703acdc1bde5.png)

[Next page](https://discourse.julialang.org/t/differential-equations-solve-top-not-defined/44510.md?page=2)
