Matlab spmd and CoolProp (CPython library)

22 次查看(过去 30 天)
Hi everone,
when i want to run the following code block in matlab spmd in Windows 11,
CP = py.importlib.import_module('CoolProp');
Fluid = CP.AbstractState("HEOS", 'water');
n = 4;
T = 300 + 273.15;
P = 100;
spmd (n)
T = T + 10*spmdIndex;
Fluid.update(CP.PT_INPUTS, P*1000, T);
Fluid.cpmass();
Fluid.rhomass();
Fluid.conductivity();
Fluid.viscosity();
end
I got the error shown in below;
Worker 1:
Warning: Unable to load Python object. Saving (serializing) Python objects into a MAT-file is not supported.
> In parallel.internal.pool.deserialize (line 33)
In parallel.internal.pool.deserializeFunction (line 17)
In spmdlang.remoteBlockExecution>iDeserializeInputs (line 59)
In spmdlang.remoteBlockExecution>iUnpackPreludeArgs (line 46)
In spmdlang.remoteBlockExecution (line 12)
Warning: Unable to load Python object. Saving (serializing) Python objects into a MAT-file is not supported.
> In parallel.internal.pool.deserialize (line 33)
In parallel.internal.pool.deserializeFunction (line 17)
In spmdlang.remoteBlockExecution>iDeserializeInputs (line 59)
In spmdlang.remoteBlockExecution>iUnpackPreludeArgs (line 46)
In spmdlang.remoteBlockExecution (line 12)
What can I do for this problem, I will be glad if you help me....

采纳的回答

Edric Ellis
Edric Ellis 2023-3-7
You need to avoid transferring the objects to the workers, and instead simply build the objects directly on the workers. The simplest way to do this is to move the lines creating CP and Fluid inside your spmd block, like this:
n = 4;
T = 300 + 273.15;
P = 100;
spmd (n)
CP = py.importlib.import_module('CoolProp');
Fluid = CP.AbstractState("HEOS", 'water');
T = T + 10*spmdIndex;
...
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Parallel for-Loops (parfor) 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by