I got an issue while parallelizing the attached code. Unfortunately it seems that ray cannot access the object spe10. The error it gives is
AttributeError: Can't get attribute 'Spe10' on <module 'spe10' (<_frozen_importlib_external._NamespaceLoader object at 0x72f785963df0>)>
The code is the following:
# Initialize Ray
ray.shutdown()
ray.init()
# Define objective_function as a Ray remote function
@ray.remote
def objective_function(pos_well):
# Call solve_fine with the appropriate arguments
result = solve_fine(spe10, pos_well, injection_rate=1, well_pressure=0, export_folder=None)
return result
# Define last_refined
last_refined = [(i, j)
for i in np.arange(200 - 3 * 6.096, 200 + 3 * 6.096, 6.096)
for j in np.arange(200 - 3 * 3.048, 200 + 3 * 3.048, 3.048)]
# Parallelize optimization using Ray for each refined cluster
futures = [objective_function.remote(pos_well) for pos_well in last_refined]
# Get results
results = ray.get(futures)
# Shutdown Ray
ray.shutdown()
As you can see the objective is to parallelize objective_function among the list last_refined which is made of tuples (x,y)
It seems that I am not able to make the object shared between workers. Does someone have some expertise to help me? Thank you very much.
Dave
I have tried to create an actor without success and to use pointers but nothing seems to work