mtex icon indicating copy to clipboard operation
mtex copied to clipboard

Unable to run Mtex with Matlab 2022b

Open fsamaraie opened this issue 1 year ago • 12 comments

Hello community ! I have been trying to run Mtex on Matlab 2022b installed on windows platform, but it keeps crashing What do you want to do? Install MTEX 5.8.2 on Windows PC What data do you have? N/A What code do you use? '''startup_mtex''' Please provide minimalist code with code in the following form

What result do you get Matlab crashes before install or startup. If open Matlab again, it crashes immediately.

What result do you expect I expect Matlab to: [1] Not crash and [2] install MTEX.

Error Message Illegal instruction detected

What MTEX version do you use? 5.8.2

fsamaraie avatar Jan 11 '23 15:01 fsamaraie

There's some info in other posts about this. Some of the mex files it's compiling might be the problem.

First... to restore Matlab not crashing after an attempt... you have to rename or remove the MTEX folder it keeps trying to install from.

Second... you'll need to find replacement mex files or pre-compiled ones... and replace the problematic ones.

For me... the problematic mex files were all for OpenMP and NFFT. There is a website that has these updated, and swapping them into the MTEX folder did the trick for me.

Such a pain tho. I'm not sure why this bug can't be fixed on the MTEX end... but it's been an issue for while now.

zmichels avatar Jan 11 '23 15:01 zmichels

@zmichels Many thanks for your help. can you direct me to the website from which I can get the OpenMP and NFFT files? Thanks again

fsamaraie avatar Jan 11 '23 17:01 fsamaraie

https://www-user.tu-chemnitz.de/~potts/nfft/download.php

zmichels avatar Jan 11 '23 17:01 zmichels

Hi, in addition to Zachs recommendation, the files are in extern/nfft_openMP, remvoe them and see if that works. If mtex starts eventually test the binaries, maybe older ones as well. If those do not work try to compile them yourself.

Since it apparently happens quite rarely with Microsoft Windows but some people encounter the issue, it might be helpful if you could also provide exact software and hardware specifications.

@zmichels To explain why it isn't so trivial to provide binaries which work for every situation and forever. a) you want a somewhat fast operation, hence you try to use openMP (which allows multicore support). However, some manufacturers, like Apple in its walled garden, does not natively ship a compiler / libraries which support that plus do not provide the infrastructure to simply install such a software. So one needs to build binaries which have all the required libraries linked into file. That works as long as something in the operation system changes to a point the binary does not run anymore. The obvious but not really practical solution would be, people should just never update their system once they have it running. Quite unrealistic. A better alternative: use a 3rd part package manager, e.g. homebrew, install the missing parts to your operation system and compile the stuff yourself. On windows this is less of an issue but the binaries from the nfft website here are compiled for halfway modern hardware e.g. see the note on older hardware here https://www-user.tu-chemnitz.de/~potts/nfft/download.php. So if you'd try to run them on something really old, they might fail. In the case someone wants to run them on pre-2013 hardware, potentially building it yourself is again the simplest solution. b) Another issue in the recent past with Macs was, that people went along and bought arm-based macs which back then were not fully supported by Matlab for some time which was the reason initially mtex did not work out of the box on those machines. c) The main reason there's no universal, always working set of binaries, for every corner case computer around is simply that there's apparently nobody who has enough time to spare (and eventually the hardware available, which would save quite time compared to cross compiling and finding people on the planet to test the results). So, sorry that it is a pain for some, but I hope the above explains a little why Matlab/Mtex might carsh for some people. Cheers, Rüdiger

kilir avatar Jan 11 '23 17:01 kilir

@kilir I totally get why it is not trivial. Just didn't used to be an issue and nowadays getting new students (many of whom are also new to coding and Matlab in general) setup is always a pain (for some I basically have to ask them to turn over their computer and let me try to get it setup). I'll add that all of the Windows desktop computers in our lab (4 in total) and 3 student newish (year old or so) Windows laptops had this exact problem -- so its definitely not just an Apple issue (though I imagine developing anything with an Apple in mind is a headache).

zmichels avatar Jan 11 '23 17:01 zmichels

@zmichels I can feel that, especially if running a course was the plan - not getting software running.

Maybe you could work out what's specific (soft&hardware) of those you have so one could reproduce what triggers them to fail would be a first step. While I do not have a windows computer, I've also never had a hand on one which failed the way described above. Also, in your case, the solution in all cases was to replace the nfft binaries from the nfft homepage?

kilir avatar Jan 11 '23 18:01 kilir

I'll try to take more notes in the future in case it helps. In each case, replacing the nfft binaries got it up and running. Its not a difficult process, just fiddly, lol. Thanks for all the info!

zmichels avatar Jan 11 '23 18:01 zmichels

Hello, Many thanks for the remarks above. My PC is DELL and runs with Intel(R) Core(TM) i7-3770S CPU @ 3.10GHz 3.10 GHz My current version of Matlab is 2022b I deleted the nfft and the nfft_openMP folder in extern. Mtex worked, but I got a warning message saying " MTEX: Error running NFFT!
The original error message was: Undefined function 'nfsftmex' for input arguments of type 'char'. I did not get NFFT working. This restricts the functionality of MTEX." I tried to compile the nfft libraries as describe in the provided link, but instead a got a definite proof that my programming skills deteriorated. I then tried to install 5.5.2 version, and it worked but gave me this message " For compatibility reasons MTEX is not using OpenMP. You may want to switch on OpenMP in the file mtex_settings.m" I am not sure if that will have alot of impact on my analysis. I am happy to further discuss this issue. Thanks again Faisal

fsamaraie avatar Jan 11 '23 18:01 fsamaraie

@fsamaraie Well the good news is that (IMO) seems to confirm that the NFFT mex files are the issue in your case. The next step is to (instead of removing them) download the Matlab NFFT binaries from the link I posted above... and find ones that match those in mtex (or just copy them all over) and swap them out... so you have the newly downloaded binaries replacing the ones in the MTEX folders. For me... after doing that... it will run without errors and be able to use OpenMP and NFFT.

zmichels avatar Jan 11 '23 18:01 zmichels

Note that an i7-3770S is a pre-Haswell CPU, so probably won't work on the binaries provided by the nfft folks.

kilir avatar Jan 11 '23 19:01 kilir

Prior to posting this issue here I contacted Matlab and about this error and they stated that the error was a result of running the nfsftmex.mexw64 file. I just downloaded the 5.6.0 and ran the startup_mtex. It ran smoothly with no errors.

fsamaraie avatar Jan 12 '23 09:01 fsamaraie

In that case you _can try to use those binaries in extern/nfft_openMP. Just copy them from the 5.6 version to the recent Mtex version into extern/nfft_openMP.

kilir avatar Jan 12 '23 11:01 kilir