Idaklu error #3193
Replies: 2 comments 7 replies
-
@jsbrittain has been working on multiprocessing and might be able to help here. See #2644 |
Beta Was this translation helpful? Give feedback.
-
@akariwrynn - Idaklu supports multithreading exactly as you have attempted through the The other issue mentioned above (#2644 ) relates to GPU acceleration for the JAX solver and has not been reviewed yet so is still in development (if you really wanted to try it out you can find the relevant branch here: see https://github.com/jsbrittain/PyBaMM/tree/jax). Note that the JAX solver is inherently multi-threaded anyway for a single PyBaMM model, the changes made in #2644 provide an interface to allow multiple simulations to run at once given a set of parameters. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I was trying to use multiprocessing with my code but appreantly pybamm seems not compatible with both multiprocessing and multithreading since they both increase the time that it takes. Therefore, I am trying to use Idaklu where I have been trying to use the example code that is published :
import pybamm
import numpy as np
construct model
model = pybamm.lithium_ion.DFN()
geometry = model.default_geometry
param = model.default_parameter_values
param.process_model(model)
param.process_geometry(geometry)
n = 500 # control the complexity of the geometry (increases number of parameters)
var_pts = {"x_n": n, "x_s": n, "x_p": n, "r_n": round(n/10), "r_p": round(n/10)}
mesh = pybamm.Mesh(geometry, model.default_submesh_types, var_pts)
disc = pybamm.Discretisation(mesh, model.default_spatial_methods)
disc.process_model(model)
t_eval = np.linspace(0, 3600, 100)
solve using IDAKLU
options = {'num_threads': 1}
for _ in range(5):
klu_sol = pybamm.IDAKLUSolver(atol=1e-8, rtol=1e-8, options=options).solve(model, t_eval)
print(f"Solve time: {klu_sol.solve_time.value1000} msecs [{options['num_threads']} threads]")
options = {'num_threads': 4}
for _ in range(5):
klu_sol = pybamm.IDAKLUSolver(atol=1e-8, rtol=1e-8, options=options).solve(model, t_eval)
print(f"Solve time: {klu_sol.solve_time.value1000} msecs [{options['num_threads']} threads]")"
But I am getting this error "C:\vcpkg\buildtrees\casadi\src\ghtly-ship-e94fd05723.clean\casadi\core\serializing_stream.cpp:355: Assertion "load_version==v" failed:
DeSerialization of ProtoFunction failed. Object written in version 2 but can only read in version 1."
My python version is 3.11.3, pybamm is 23.5. How can I solve this or is there someone using multiprocessing or multithreading for pybamm simulations?
Thanks a lot,
Eren
Beta Was this translation helpful? Give feedback.
All reactions