-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Matlab function not responding after certain times of calls. #255
Comments
I am mystified. I have no idea where that kind of behavior would arise. |
Hi Arokem, thanks for replying. I'm surprised to be met with this kind of issue, too. Have you got any chance to try the scripts in my original post? It is nothing but calling the example "jk.m" function over and over in a loop. I'd like to understand if it is anyway reproducible in other user's environment. |
Hi @arokem, thanks for this really helpful library! I have a similar problem to the one described in this issue and I was able to break it down a bit more: I don't even need to call any special matlab function for that. All I have to do is to send numpy arrays to matlab. mlab = Matlab(log=False)
mlab.start()
for i in range(1000):
print(i)
mlab.set_variable('foo', np.array([42])) This fails reproducibly in the 207th interation (although sometimes I have experienced the hang to occur a few iterations earlier, but always after the 200th iteration). It doesn't seem to depend on the size of the arrays: For comparison, I also tried to retrieve variables in stead of setting them: mlab.run_code('a =randn(1000, 1000);')
for i in range(10000):
a = mlab.get_variable('a') This also fails reproducibly, but already after 106 iterations. It again seems to be independent of the shape of the variable: The first idea that comes to my mind is that the library is filling up some buffer that doesn't get deleted? Maybe in zmq? When I then interrupt (in the jupyter notebook, but it is reproducible in ipython), I get this stacktrace:
and the notebook server itself additionally prints
I'm using ubuntu 16.04, Matlab R2016b. If there is anything I can do to further help debugging this issue, I would be happy to try it. |
This happens both with version 0.5.2 from pypi and the master branch from this repository. |
By the way, I did not yet manage to access the matlab log. If I set |
Hi! I'm having a similar problem with Matlab2021a and Ubuntu 18.04, it freezes when executing the same function many times. However, if I stop and start the session every few (let say 10) iterations it takes way much more time to freeze. I'm not sure how it works in the background this matlab bridge, but maybe this information is useful for you. |
First of all, I have to say this python-matlab-bridge is great, very easy to use, very helpful examples. However I am met with this issue that I think has not been raised by other users. I'm trying to call a Matlab function over and over and I find it always fails at a certain numbers of calls. To illustrate, I attach the code and output below:
Code starts*************************
import sys
import os
from pymatbridge import Matlab
mlab = Matlab(executable='/Applications/MATLAB_R2017a.app/bin/matlab')
mlab.start()
matlab_call_cnt = 0
while True:
matlab_call_cnt+=1
print(matlab_call_cnt)
res = mlab.run_func('/Users/shenglinli/PycharmProjects/pymat_test/jk.m', {'arg1': 3, 'arg2': 5})
print(res['result'])
mlab.stop()
Code ends*************************
And it will print number of Matlab function calls and the result of the "jk.m" function which is 8. So it goes like:
Output starts*************************
Starting MATLAB on ZMQ socket ipc:///tmp/pymatbridge-849ff32d-88b6-4a38-8509-7f59d3a705c1
Send 'exit' command to kill the server
........MATLAB started and connected!
1
8
2
8
3
8
4
8
...
269
8
270
8
271
Output ends*************************
Basically I find that it always stuck at 271st call of Matlab function, 100% repeatable. It seems like python sends request to Matlab server and does not get a response on that function call. I'd really appreaciate it if someone can share some insight on this issue.
And below are my settings:
OSX
Matlab R2017a
Current libzmq version is 4.1.6
Current pyzmq version is 16.0.2
Thanks!
The text was updated successfully, but these errors were encountered: