How can I run matlab code on a unix server processing batch jobs ?

57 views (last 30 days)
Hello,
First a simpler version: Let's say I want to run a script test1.m on Unix.
On the unix server command line, if I simply type:
matlab -nodisplay test1.m
I can see that it runs fine.
Now, through this unix server, I want to submit batch jobs which are run on another cluster of machines.
In the past, I have been able to do this using something like:
bjob (server details etc) matlab -nodisplay <test1.m>
However, I tried to do this on a new cluster now, and it does not work, exiting with a message like
| Exit Status : -4 |
NB: Job execution failed on remote machine
I have been told that the cluster servers probably do not take "matlab" command directly, and an executable file needs to be provided (there were mentions of mcc and makefile etc also in the conversation) So how do I generate this executable file and get this to work ?
While any answers to the above will help me understand the overall idea, the matlab code that I actually want to run is not just 1 single script (test1.m), but involves calls to other .m subroutines as well as to .mex files. Please point out what additional (if any) tasks would be required in this case.
Thanks a lot for your help.
  3 Comments
Singh J
Singh J on 14 Feb 2017
Edited: Singh J on 15 Feb 2017
Hi..thanks. This also does not work for me. In any case, could you please point out the importance of "-r" (I have used it in past without knowing what it really does, and surprisingly it appears to be terribly hard to figure out the purpose of '-r' using google search) Please also explain your suggestion "try; test1; end; quit".
Walter Roberson
Walter Roberson on 15 Feb 2017
When you use
matlab -nodisplay test1.m
then you are giving a file name and hoping it knows what to do with it.
When you use
matlab -nodisplay -r test1
then you are giving MATLAB a command, telling it to execute "test1" as if you had given that at the command line.
matlab -nodisplay -r "try; test1; end; quit"
then you are telling it to run "try; test1; end; quit" as if done at the command line. That has the advantage if if something bombs while executing test1 then you are sure that the error will be caught cleanly and that you will proceed to the "quit". Historically, there were situations in which an error while executing could lead MATLAB to sit spinning its wheels or perpetually trying to input a command, having that fail, trying again, and so on, not recognizing that the End Of File should mean that it should exit.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 15 Feb 2017
"I have been told that the cluster servers probably do not take "matlab" command directly, and an executable file needs to be provided (there were mentions of mcc and makefile etc also in the conversation)"
MATLAB itself can be installed on servers. As usual, a license is needed.
If you have a Professional / Standard "Named User" license, then it could be your existing license: the Professional / Standard license allows you to install on up to four machines simultaneously and to execute on up to two of them at the same time. In that situation, you would be the only person who could execute MATLAB, which would not necessarily be a problem.
If multiple people would need to use MATLAB this way, then other licenses would be needed, such as Networked Named User licenses, or Networked Floating licenses.
Now, if you have a particular program to run with MATLAB, and if you have the MATLAB Compiler, and your code does not happen to use anything unsupported, then it is possible to generate an executable that performs that one task. No license would be required to run that executable (the Compiler costs a lot, to cover the loss of income implied by running the generated programs without a license.) This is the situation in which mcc and makefiles would be used, to generate the executable. Some programs only take a few minutes to adapt for compiling; some programs take months of effort to compile properly.
If your code is designed using the Parallel Computing Toolbox, then to run properly on a server might call for the MATLAB Distributed Computing Server product, which traditionally was expensive (I do not know about now.)

Categories

Find more on MATLAB Parallel Server in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!