Calling python functions from MATLAB workers

与世无争的帅哥 提交于 2021-01-28 04:52:49

问题


I'm trying to run a MATLAB script using parfor which runs a simulink model in parallel by sim function, and this simulink model contains a MATLAB Function Block.

The function defined in this block calls a python function using "py." mechanism.

Unfortunately, the run sometimes seems stuck in the middle, when I fed a large number of simulations. The debugging output stops to show up. I suspect a deadlock somewhere.

So, my questions are

  • Can we run a simulink model which contains python functions in parallel?
  • In what way MATLAB calls the python interpreter? One for each MATLAB worker or One for the entire MATLAB?

I use MATLAB R2017b on Mac.

Addition of March 22, 2018: I contacted to the support and they responded that calling a python function from a MATLAB function block in a simulink model is not supported and anything can happens. Still I'm interested in how MATLAB interacts with (a) python interpreter(s). Is there a single python interpreter which interacts with the whole MATLAB or are there multiple python instances for all MATLAB workers?

Addition of April 22, 2018: Updating MATLAB 2018a seems fix the problem

来源:https://stackoverflow.com/questions/49354940/calling-python-functions-from-matlab-workers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!