Fast ODE solver for PyMC3

Hi everyone,

I am new to Bayesian inference, and especially to PyMC3. I am currently working on a MCMC model with differential equations. I have tried pymc3.ode.DifferentialEquation but I am not happy with the performance as my code run super slow.

Can anyone suggest how the best ODE solver to work with PyMC3? Was thinking about scipy ODE solver, but could not find any example that I can easily understand and adapt to my model, and I am wondering will the performance be a lot better compared to pymc3.ode.DifferentialEquation?

Any suggestions are welcome!


You want SunODE: GitHub - aseyboldt/sunode: Solve ODEs fast, with support for PyMC3


Thanks for your reply. I tried installing SunODE but I am still facing some problems which I believe something related to Theano. I installed both PyMC3 and SunODE via conda
conda install -c conda-forge pymc3
conda install sunode

Yet, here are the error messages when I tried running the example code:

Traceback (most recent call last):
  File "/home/mardian/anaconda3/envs/sunode-env/lib/python3.9/site-packages/sunode/wrappers/", line 2, in <module>
    import aesara
ModuleNotFoundError: No module named 'aesara'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/mardian/bayesian_inference/", line 3, in <module>
    import sunode.wrappers.as_theano
  File "/home/mardian/anaconda3/envs/sunode-env/lib/python3.9/site-packages/sunode/wrappers/", line 1, in <module>
    from . import as_theano as as_aesara
  File "/home/mardian/anaconda3/envs/sunode-env/lib/python3.9/site-packages/sunode/wrappers/", line 12, in <module>
    from theano.gof.var import Constant, Variable
ModuleNotFoundError: No module named 'theano.gof.var'

Do you know what might cause this?

Also, is there anyway to install SunODE via pip?

Yes, you need to install aesara instead of Theano, and try with the pymc main channel.