Difference between revisions of "Matlab"

Jump to navigation Jump to search
Line 17: Line 17:
Then you need to setup your environment so that the proper libraries are available for use by Matlab:
Then you need to setup your environment so that the proper libraries are available for use by Matlab:
  $ export LD_LIBRARY_PATH=/apps/matlab/bin/glnxa64:/apps/matlab/sys/os/glnxa64
  $ export LD_LIBRARY_PATH=/apps/matlab/2008a/bin/glnxa64:/apps/matlab/2008a/sys/os/glnxa64
  $ export PATH=${PATH}:/apps/matlab/bin
  $ export PATH=${PATH}:/apps/matlab/2008a/bin
'''These environment settings will also need to be in place for when you run the executables that are produced in this method.
'''These environment settings will also need to be in place for when you run the executables that are produced in this method.

Revision as of 18:41, 14 November 2008


Currently matlab is located here:

Version 2007a: /apps/matlab/2007a/

Version 2008a: /apps/matlab/2008a/


Please remember that the HPC Center resources are not to be used interactively! Matlab jobs should be submitted via Torque submission scripts with no user interaction.


In order to compile matlab programs on the HPC cluster so that they will be usable by the batch system, you need to do a couple of things.

First, log into one of the test nodes; these are named test03, test04, and test05. The test nodes are where you do Matlab compilations. Don't try to compile Matlab jobs on submit.

Then you need to setup your environment so that the proper libraries are available for use by Matlab:

$ export LD_LIBRARY_PATH=/apps/matlab/2008a/bin/glnxa64:/apps/matlab/2008a/sys/os/glnxa64
$ export PATH=${PATH}:/apps/matlab/2008a/bin

These environment settings will also need to be in place for when you run the executables that are produced in this method. Once your environment is ready, you can compile your matlab .m files so that they will be usable as binaries. We use the mcc command for this.


Let us say that we have a program called houdin.m, which looks like this:

function [m,t] = houdini();
% Doc example, chapter 3.

% Copyright 1997 The MathWorks, Inc.
% $Revision: $

m = magic(2); % Assign 2x2 matrix to m. 
t = m .^ 3;   % Cube each element of m. 
disp(t);      % Display the value of t.

Since we already have the environment setup, we can compile this program. It is recommended that this be done in a separate directory as a number of files are produced.

$ mkdir tmp
$ cd tmp
$ cp ../houdini.m .
$ ls
$ export LD_LIBRARY_PATH=/apps/matlab/bin/glnxa64:/apps/matlab/sys/os/glnxa64
$ export PATH=${PATH}:/apps/matlab/bin
$ mcc -m houdini.m 
Warning: Unable to open display , MATLAB is starting without a display.
  You will not be able to display graphics on the screen.
$ ls -l
total 124
-rwxr-xr-x  1 root root 12299 Apr  3 10:08 houdini
-rw-r--r--  1 root root 63146 Apr  3 10:08 houdini.ctf
-rw-r--r--  1 root root   239 Apr  3 10:06 houdini.m
-rw-r--r--  1 root root  2900 Apr  3 10:08 houdini_main.c
-rw-r--r--  1 root root  6328 Apr  3 10:08 houdini_mcc_component_data.c
-rw-r--r--  1 root root  5461 Apr  3 10:08 houdini.prj
-rw-r--r--  1 root root  1010 Apr  3 10:08 mccExcludedFiles.log
-rw-r--r--  1 root root  6757 Apr  3 10:08 readme.txt
-rwxr--r--  1 root root  1446 Apr  3 10:08 run_houdini.sh

So there we have it. A binary executable houdini has been produced.

For more information, documentation for the Matlab Compiler can be viewed at the Matlab Website.

Frequently Asked Questions

Dear Sirs,

 I have a basic question about what can be run on the cluster. I have a
 standalone C application file generated by the Matlab compiler. Is it
 possible to run it (after porting/copying the required libraries) as an
 external application on a particular node of the cluster. This is
 because it is not possible for me to compile the C source files on the
 cluster itself?

OK... from what I gather here, I think you have the following:

  1. A compiled executable, most likely in linux x86 format.
    This executable obviously requires specific libraries to run, and if we don't have them installed they won't work. From what I remember of the matlab compiler suite, it is possible for the matlab compiler to actually generate a full set of files that include your executable and the libraries it needs to support it such that the whole suite is portable. This is what you really want to look for, and I know it has been done before.
  2. Possibly the source code.
    If you have the C source code, you should be able to compile that source code on our systems with out any trouble, unless it requires some sort of library provided by matlab. If this is the case, then option 1 above is your best bet.

Where is the Distributed Computing Toolbox?

It hasn't been added because we do not have a license for the distributed computing toolbox. The University of Florida has not opted for that particular option, and our group does not have the money to purchase this particular license, as it is very expensive.

Compiled DLL

If you have compiled a DLL to use as an executable, it will not work on the cluster. DLL's are Microsoft Windows based dynamically linked libraries that matlab would be able to run on a Windows machine in a faster method because it would not have to do any compiling of its own. Basically it is the same thing as a matlab byte-compiled package. A number of different software packages and languages out there use the same methodology, such as Java and emacs-lisp.

Setting a Path

In order to set a path, in your matlab script you would put the following:

path(path, '/path/to/wherever/you/want')

This would add a search path to the matlab system. This is also detailed on the Matlab website.



When version 2008a was installed on our system, it installed fine but when run it would complain about glibc being too old. The error message given my matlab looked like the following:

Error: The MATLAB script returned a bad status while determining
       environment variables. There appears to be a problem
       with your MATLAB installation. You must fix the problem
       before mcc can work. Any messages from the script
       follow . . . 

Warning: glibc 2.3.4      - Unsupported version
         glibc 2.3.6      - MATLAB built using this version
-> Your configuration APPEARS to be too OLD to run this MATLAB program!
   For system requirements consult http://www.mathworks.com ...


In order to fix this problem, we first searched on the web to find that there was a patch available from Mathworks if you asked them for it. We did just this, and the fix turned out to be very simple. Unfortunately it appears that no one else has bothered to publish this fix, so here it is:

--- oscheck.sh    2008-05-28 09:48:55.000000000 -0400
+++ oscheck.sh.old    2007-12-02 01:34:35.000000000 -0500
@@ -102,7 +102,7 @@
#                  of the data. Set oscheck_debug=0 for shipping.
# Copyright 1996-2007 The MathWorks, Inc.
-# $Revision: $  $Date: 2008/03/24 17:59:41 $
+# $Revision: $  $Date: 2007/12/03 21:53:17 $

@@ -153,8 +153,8 @@ else
#                   arch   OSprefix minimum_ver release_ver future_ver
oslist="        sol64   SunOS    5.10         5.10         -"
-        oslist="$oslist glnx86  glibc    2.3.4       2.3.4       -"
-        oslist="$oslist glnxa64 glibc    2.3.4       2.3.4       -"
+        oslist="$oslist glnx86  glibc    2.3.6       2.3.6       -"
+        oslist="$oslist glnxa64 glibc    2.3.6       2.3.6       -"
oslist="$oslist mac     Darwin   8.7.0       8.7.0       -"
oslist="$oslist maci    Darwin   8.7.0       8.7.0       -"
oslist="$oslist maci64  Darwin   9.0.0       9.0.0       -"

Compiler Issues

You may run into an error when using the matlab compiler that looks something like this:

Licensed number of users already reached.

In this case what is probably happening is that the number of licenses for the matlab compiler has been exhausted. The University only has two licenses, and if they are currently being used then this is the error that will be issued.