I need to run a function in parallel for different input values. The thing is that I need to get the output (a NetworKit Graph) of the function for each iterations. I tried to use joblib
, Multiprocessing.Process
and Queue
, pathos
, but I always have the same error
can't pickle _NetworKit.Graph objects
Here is a snippet of the code I'm trying to parallelize, with an example with joblib
:
from networkit import Graph
from joblib import Parallel, delayed
def f( i ):
graph = networkit.Graph()
graph.addNode()
# ... Some other graph computations ...
return graph
res = Parallel( n_jobs = 2 ) ( delayed( f )( i ) for i in np.arange( 5 ) )
I understand that all these libraries use pickle
to serialize an object and that networkit
objects are not pickable. I read that dill
allows us to pickle non pickable objects, does anyone have any experience with dill
using multiprocessing ?
Otherwise, is there any way to accomplish what I need ?
Thank you !