Pymatmodule.so for Matlab 7.0.1 and FC3: strange behavior
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
Pymatmodule.so for Matlab 7.0.1 and FC3: strange behavior
Hi everybody,
I thought I had managed to compile pymatmodule.so for matlab7.0.1 and Fedora Core 3 (for BrainVISA 3.0).
I have two python programs (programA and programB, with associated matlab codes) that were running successfully with the previous release. I did not find any big difference between them. I mean, they both contain lines like
MODELE = matlab.matlab()
MODELE.put( "c0", self.foo )
MODELE.eval( '[a,b] = foobar(c0)' )
Now let us run programA in BrainVISA. It runs fine.
Now I run programB. It puts correctly all variables in the matlab workspace. But then it crashes with the following message:
===================================================================
RuntimeError: Unable to evaluate string in MATLAB workspace
neuroProcesses.py (1476) in _processExecution: result = process.execution( self )
DDG_simulation.py (173) in execution:
SIMU.eval( "[data, params] = DDG_load_params(TMfile,maskfile,C0file,c0,rho,Dg,Dw,r,nt,proliferation,isiso)" )
matlab.py (99) in eval:
error = self._callMatlabThread.call( self._eval, expression )
threadCalls.py (93) in call:
raise e
==================================================================
If I try programA again, or if I run programB again, both programs crash at the FIRST "put" instruction, with the following error message:
==========================================================
RuntimeError: Unable to put matrix into MATLAB workspace
neuroProcesses.py (1476) in _processExecution:
result = process.execution( self )
modele.py (37) in execution:
MODELE.put( "c0", self.initial_concentration )
matlab.py (131) in put:
return self._callMatlabThread.call( self._put, *args, **kwargs )
threadCalls.py (93) in call:
raise e
===========================================================
Does it look like a thread problem ? Is my pymat installation not correct ? Any hint/suggestion would be very much appreciated
BTW, if you ask me whether it makes a difference if I first run programB before programA, well, it does . ProgramB crashes at once while programA runs fine the first time. But
- I don't see any bug neither in programA nor in programB (I know, there may be a bug anyway, I'm still searching...)
- both programs were running with the previous release...
Melanie
I thought I had managed to compile pymatmodule.so for matlab7.0.1 and Fedora Core 3 (for BrainVISA 3.0).
I have two python programs (programA and programB, with associated matlab codes) that were running successfully with the previous release. I did not find any big difference between them. I mean, they both contain lines like
MODELE = matlab.matlab()
MODELE.put( "c0", self.foo )
MODELE.eval( '[a,b] = foobar(c0)' )
Now let us run programA in BrainVISA. It runs fine.
Now I run programB. It puts correctly all variables in the matlab workspace. But then it crashes with the following message:
===================================================================
RuntimeError: Unable to evaluate string in MATLAB workspace
neuroProcesses.py (1476) in _processExecution: result = process.execution( self )
DDG_simulation.py (173) in execution:
SIMU.eval( "[data, params] = DDG_load_params(TMfile,maskfile,C0file,c0,rho,Dg,Dw,r,nt,proliferation,isiso)" )
matlab.py (99) in eval:
error = self._callMatlabThread.call( self._eval, expression )
threadCalls.py (93) in call:
raise e
==================================================================
If I try programA again, or if I run programB again, both programs crash at the FIRST "put" instruction, with the following error message:
==========================================================
RuntimeError: Unable to put matrix into MATLAB workspace
neuroProcesses.py (1476) in _processExecution:
result = process.execution( self )
modele.py (37) in execution:
MODELE.put( "c0", self.initial_concentration )
matlab.py (131) in put:
return self._callMatlabThread.call( self._put, *args, **kwargs )
threadCalls.py (93) in call:
raise e
===========================================================
Does it look like a thread problem ? Is my pymat installation not correct ? Any hint/suggestion would be very much appreciated
BTW, if you ask me whether it makes a difference if I first run programB before programA, well, it does . ProgramB crashes at once while programA runs fine the first time. But
- I don't see any bug neither in programA nor in programB (I know, there may be a bug anyway, I'm still searching...)
- both programs were running with the previous release...
Melanie
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
A little more about my problem... in case it helps...
I've tried to evaluate my matlab function foobar.m step by step in BrainVISA. Needless to say that the function runs fine in matlab outside pymat, of course.
In BrainVISA, it crashes at a line that calls an SPM99 function : spm_slice_vol.
As far as I've understood, this function is a compiled mex file. Could there be a problem between mex files and pymat ??? How could I check ?
HELP !!!!
Melanie
I've tried to evaluate my matlab function foobar.m step by step in BrainVISA. Needless to say that the function runs fine in matlab outside pymat, of course.
In BrainVISA, it crashes at a line that calls an SPM99 function : spm_slice_vol.
As far as I've understood, this function is a compiled mex file. Could there be a problem between mex files and pymat ??? How could I check ?
HELP !!!!
Melanie
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Well, the mex question is something I never wondered about...
How does matlab 7 handle mex compiled on matlab 6 ? Maybe you have to recompile them with matlab 7 ?
If they are working like that when matlab is run directly, I agree it should not be different via the pymat module, but comuters are complicated things (especially when matlab is involved) and we know matlab7 not to work with a pymat module built on matlab6, so...
Moreover, does SPM99 work well with matlab7 ? I think people here have said it doesn't - maybe with patches ?
Denis
How does matlab 7 handle mex compiled on matlab 6 ? Maybe you have to recompile them with matlab 7 ?
If they are working like that when matlab is run directly, I agree it should not be different via the pymat module, but comuters are complicated things (especially when matlab is involved) and we know matlab7 not to work with a pymat module built on matlab6, so...
Moreover, does SPM99 work well with matlab7 ? I think people here have said it doesn't - maybe with patches ?
Denis
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
As far as I know, I've updated my SPM software so that it should get on quite well with matlab7. At least, it hasn't crashed so far. But I'm not experiencing it very often .
My pymatmodule has been recompiled for matlab7. If I try to run with matlab7 a pymatmodule that has been compiled with matlab6, it crashes at once. Here, however, some of my python-matlab programs DO run.
Maybe it has something to do with the libgcc thing (that of matlab replaced by that of FC3) so I'll try to recompile the mex anyway, but I still don't understand why it would run in matlab but not with pymat
I'll let you know.
Melanie
My pymatmodule has been recompiled for matlab7. If I try to run with matlab7 a pymatmodule that has been compiled with matlab6, it crashes at once. Here, however, some of my python-matlab programs DO run.
Maybe it has something to do with the libgcc thing (that of matlab replaced by that of FC3) so I'll try to recompile the mex anyway, but I still don't understand why it would run in matlab but not with pymat
I'll let you know.
Melanie
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
It's not a Mex file problem after all...
I've gone on looking through my codes, and I ended up with the very interesting following test :
I tried to multiply 2 matrices in matlab (silly idea, isn't it ?).
b = eye(2) * [2 0; 0 3];
- In matlab, it works fine.
>> b = eye(2) * [2 0; 0 3]
b =
2 0
0 3
- In a terminal, using python and the pymat module, it works fine.
Python 2.4.1 (#1, Sep 16 2005, 10:15:14)
[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymat
>>> H = pymat.open()
>>> pymat.eval(H, 'b = eye(2) * [2 0; 0 3]')
>>> b = pymat.get(H, 'b')
>>> print b
array([[2.0, 0.0], [0.0, 3.0]], 'd')
- in BrainVISA, it crashes.
I used "import matlab" at the beginning of the python code
and something like
MODELE = matlab.matlab()
MODELE.eval( 'b = eye(2) * [2 0; 0 3]')
I get "unable to evaluate string in matlab workspace".
Any hint ???
I tried to multiply 2 matrices in matlab (silly idea, isn't it ?).
b = eye(2) * [2 0; 0 3];
- In matlab, it works fine.
>> b = eye(2) * [2 0; 0 3]
b =
2 0
0 3
- In a terminal, using python and the pymat module, it works fine.
Python 2.4.1 (#1, Sep 16 2005, 10:15:14)
[GCC 3.4.4 20050721 (Red Hat 3.4.4-2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymat
>>> H = pymat.open()
>>> pymat.eval(H, 'b = eye(2) * [2 0; 0 3]')
>>> b = pymat.get(H, 'b')
>>> print b
array([[2.0, 0.0], [0.0, 3.0]], 'd')
- in BrainVISA, it crashes.
I used "import matlab" at the beginning of the python code
and something like
MODELE = matlab.matlab()
MODELE.eval( 'b = eye(2) * [2 0; 0 3]')
I get "unable to evaluate string in matlab workspace".
Any hint ???
- riviere
- Site Admin
- Posts: 1361
- Joined: Tue Jan 06, 2004 12:21 pm
- Location: CEA NeuroSpin, Saint Aubin, France
- Contact:
Hi Mélanie,
I have tried your test here on FC2 using matlab 7.0.2 and it works well for me.
So it seems to be related to FC3 (maybe the libgcc_s).
Do you have the opportunity to test it with matlab 6.5 ?
We're struggling with matlab here too - I've just managed to make a system that automatically switches to a pymat module corresponding to the right matlab version (they are named pymat6, pymat7...) if several pymat modules are compiled. In the next update, on linux at least you will have the choice to use matlab 6 or 7. But we're not running FC3...
Denis
I have tried your test here on FC2 using matlab 7.0.2 and it works well for me.
So it seems to be related to FC3 (maybe the libgcc_s).
Do you have the opportunity to test it with matlab 6.5 ?
We're struggling with matlab here too - I've just managed to make a system that automatically switches to a pymat module corresponding to the right matlab version (they are named pymat6, pymat7...) if several pymat modules are compiled. In the next update, on linux at least you will have the choice to use matlab 6 or 7. But we're not running FC3...
Denis
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
Yes (my thanks to Denis Schwartz ), I tested with Matlab 6.5 and I do not have the problem any more. So I would conclude to a bug (a thread problem?) specific to the combination Matlab7/FC3...
I will be keeping matlab 6.5 for some time (but now I face backward compatibility problems because some of my programs written with matlab 7 do not run under matlab 6.5 ). Anyway, if someone finds the solution I would be very happy
I will be keeping matlab 6.5 for some time (but now I face backward compatibility problems because some of my programs written with matlab 7 do not run under matlab 6.5 ). Anyway, if someone finds the solution I would be very happy
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris
- Melanie PELEGRINI
- Posts: 39
- Joined: Tue Mar 23, 2004 4:20 pm
- Location: U678 Inserm, Paris