Matlab

From UFRC
Jump to navigation Jump to search

Installation

Currently matlab is located here:

Version 2009b: /apps/matlab/2009b/

Policies

  1. You may not run MatLab nor compiled MatLab executables interactively on submit1 or submit2.
  2. You must use the test nodes (test01 - test05) to test and compile your MatLab programs.
  3. Long running (more than 30 minutes) MatLab jobs must be submitted to the batch system.
  4. Large numbers of jobs must not be run on the test nodes but must be submitted to the batch system.
  5. The UF HPC Center has no budget for application software and licensing. All MatLab licenses (including the compiler) come from, and are shared with, all of campus. For this reason it is sometimes difficult to obtain a license. If your research depends on MatLab and you do not want to be delayed by licensing issues, you should consider purchasing a MatLab license for your personal or group use.

Compiling MatLab Programs

MatLab programs must be compiled via the MatLab compiler before they can be run in batch mode on the HPC Center cluster. In order to compile MatLab programs you should

1. Once on submit1 or submit2, log into one of the test nodes (test01 - test05) via ssh. Due to user memory constraints on submit1 and submit2, the MatLab compiler cannot be used on them.

submit1% ssh test05

2. Set up your environment so that the libraries needed by the compiler can be found.

 test05% export LD_LIBRARY_PATH=/apps/matlab/2009b/bin/glnxa64:/apps/matlab/2009b/sys/os/glnxa64
 test05% export PATH=${PATH}:/apps/matlab/2009b/bin

Note: These environment settings should be included in your batch submission script since they will also be needed by the resulting MatLab executable.

3a. For batch jobs, you should also set the MCR_CACHE_ROOT environment variable in your PBS job script.

 test05% export MCR_CACHE_ROOT=${TMPDIR}

Please see the PBS Sample Job Scripts for a sample MatLab submission script.

3b. For an interactive run (only on the test nodes), you should set MCR_CACHE_ROOT to a directory /scratch/local.

 test05% mkdir -p /scratch/local/$USER/mcr_cache
 test05% export MCR_CACHE_ROOT=/scratch/local/$USER/mcr_cache

4. Compile your matlab program (.m) files using the MatLab compiler (mcc).

 test05% mcc -R -singleCompThread -m some_prog.m

Example

Let us say that we have a program such as that below in a source file named houdini.m

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

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

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.

 test05% mkdir tmp
 test05% cd tmp
 test05% cp ../houdini.m .
 test05% ls
houdini.m
 test05% export LD_LIBRARY_PATH=/apps/matlab/2009b/bin/glnxa64:/apps/matlab/2009b/sys/os/glnxa64
 test05% export PATH=${PATH}:/apps/matlab/2009b/bin
 test05% mcc -R -singleCompThread -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.
 test05% 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

The MatLab executable houdini has been generated.

Note: The "-R -singleCompThread" options on the mcc command line will result in a single-threaded executable. By default, multi-threading is enabled in executables produced by mcc. The result is that one computational thread will be started for each processor in a machine that runs your executable. That's not usually what you want. Unless you know what you are doing and intend to take advantage of multithreading (including requesting the appropriate resources in your submission script) you should use these options and generate a single-threaded executable. Otherwise, your MatLab jobs will oversubscribe the compute nodes and interfere with other users' programs.


Documentation for the MatLab compiler can be viewed on the MatLab Website.


Is the Distributed Computing Toolbox available?

No, not at this time. The University of Florida has not purchased a license for that product. The HPC Center has no budget for application software or licensing. Users and/or groups must purchase commercial software on their own.

Compiled DLL

If you have compiled a DLL to use as an executable, it will not run on the cluster. DLL's are Microsoft Windows based dynamically linked libraries that will only work under the Windows operating system.

Setting a Path

In order to set a path in your MatLab program should add the following code.

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

This would add a search path to the MatLab system. For more information see Matlab web site.

Troubleshooting

2008a

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: 1.1.12.1 $  $Date: 2008/03/24 17:59:41 $
+# $Revision: 1.1.6.4 $  $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.

"Could not access the MCR component cache." error message

What is happening here is that matlab is not able to access the MCE cache directory, which it expects to be in your home directory. The reason this is happening is that we have found that when a large number of these programs are running at the same time, the load on the home area file system is too great, and we start having problems with the filesystem.

In order to solve this problem, you just need to do the following:

export MCR_CACHE_ROOT=$TMPDIR

This redirects the cache to a temp directory that is able to handle the traffic.

Installation Notes

Licensing

The matlab license is a floating license provided to us from the University. As such, we cannot be using hundreds if not thousands of licenses from this provision, as we would completely wipe out the ability of the rest of the university to use the software.

As such, matlab licenses can only be used from select machines, typically submit and test nodes.

This is done by copying /etc/matlab.dat from submit to whatever nodes need to have the license. The software installation of matlab in /apps has a symbolic link to this file, so if the file is there it can read the license, and if not the software will not work.

Installation Notes

See matlab installation for more details.