How to use EnsembleDistributed() in DifferentialEquations.jl

I was following a tutorial in Stochastic Differential Equations · DifferentialEquations.jl (sciml.ai) and tried to modify it to use EnsembleDistributed() to speed up MC simulations.

This is from the tutorial:

using DifferentialEquations
α=1
β=1
u₀=1/2
f(u,p,t) = α*u
g(u,p,t) = β*u
dt = 1//2^(4)
tspan = (0.0,1.0)
prob = SDEProblem(f,g,u₀,(0.0,1.0))

Then I tried to use EnsembleDistributed():

using Distributed
ensemble_prob = EnsembleProblem(prob)
addprocs(3)
sol = solve(ensemble_prob,EnsembleDistributed(),trajectories=10)

But it didn’t work and I got the following errors:

On worker 2:
KeyError: key DiffEqBase [2b5f629d-d688-5b77-993f-72d75c75574e] not found
[...]

I tried two different machines but got similar errors. I wonder what I’m missing here.

With @everywhere using DifferentialEquations, it worked.

1 Like

Yeah the issue was that the packages were not loaded on the remote machines. Glad to hear you figured that out.

1 Like