Deploying MATLAB Executables with Release 14 SP2

Deploying MATLAB Executables under MATLAB R14 SP2

Assuming you have figured out how to compile MATLAB, the following shows you how to deploy MATLAB executables on LSC grid computers.
If you haven't setup up MATLAB compiling, go to this web page on MATLAB compilation.
The technique for deploying MATLAB executables on stand-alone grid computers with independent disk systems (such as Penn State's Pleiaides) can differ from that on grid computers (such as those on the main LSC grids CIT, LHO and LLO) that share disks with the development nodes where a MATLAB installation resides
Deploying executables on stand-alone grids (Pleiades) or
Deploying executables on main LSC grids

Deploying executables on stand-alone grids(Pleiades)

To run MATLAB executables on grid computers without MATLAB installed (or without access to the MATLAB installation files), we need to install the MATLAB Component Runtime (MCR) files on that system. Such systems include Pleiades and other LSC Tier 2 computers.

1) Check if MCR is already set up

Often, the Grid computer sys-admin has already installed this. If that is the case, obtain the location of the MCR installation from them and jump to step 4)

2) Get MCR Installer file (MCRInstaller.zip)

This can be created using the buildmcr command within MATLAB. Because the user may not be allowed to write into the default MATLAB directory, we have it create that file locally. Use the following at the MATLAB prompt
% buildmcr('.');
This will take some time. A copy of the installer is stored on the Gravity cluster at ~s4/no-backup/Matlab_MCR/v72.

3) Transfer and install on Grid computer

If it doesn't exist, create a MCR sub-directory on the grid computer off your home directory using gsh.pl
[thorne@auriga ~]$ gsh.pl
gsh version: $Id: gsh.pl,v 1.12 2004/02/10 22:15:16 mcnabb Exp $
time left for grid-proxy: 131:18:51 (5.5 days)
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> mkdir MCR

2) Copy the MCRInstaller.zip for v7.2 to your home directory on the grid computer
ligo-grid.aset.psu.edu:/usr18/home/ux001007/ put MCRInstaller.zip

3) Unzip the MCR Installer on the grid computer using unzip and then exit gsh.pl
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> unzip MCRInstaller.zip -d MCR
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> quit

** this creates a v72 sub-directory under the MCR directory

4) Put script with MCR in LD_LIBRARY_PATH on Grid computer

To use MCR on the grid computer, the MCR needs to be added to the LD_LIBRARY_PATH.
This is similar to the setup above, but for MCR directories. Here it is for csh:
setenv MCR_ROOT ${HOME}/MCR/v72
if ( $?LD_LIBRARY_PATH ) then
    setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386:${LD_LIBRARY_PATH}
else
    setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386
endif
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386/client:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/os/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/bin/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/runtime/glnx86:${LD_LIBRARY_PATH}
setenv XAPPLRESDIR ${MCR_ROOT}/X11/app-defaults
setenv ARCH glnx86
Note the addition of ARCH. This is needed to fix a problem in calling Ghostscript when creating figures in compiled code. There is a sample csh file (MCRSetup.csh) available to use as well. Transfer this file to the Grid computer (using gsh.pl)
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> put MCRSetup.csh

5) Transfer MATLAB executable to Grid computer

You must move both the compiled executable and the .ctf file to the Grid computer. If doing it statically and assuming 'matlabproc' is the executables, then use
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> mkdir Exectuables
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> cd Executables
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> put matlabproc
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> put matlabproc.crf
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> chmod 755 matlabproc
ligo-grid.aset.psu.edu:/usr18/home/ux001007/> quit

5) Create script to run MATLAB executable on grid

I have found it easier to use a shell script as the 'executable' under condor. Since you can place the MATLAB compiled executable in directories visible from the condor grid nodes, your script can concentrate on setup concerns. Assuming
a) your home directory is /usrxx/home/griduser on ligo-grid.aset.psu.edu
b) your MATLAB exectuable is named 'matlabprog' and is in sub-directory 'Executables'
c) you have put the MCRSetup.csh script in your home directory on the grid computer
then the following is needed in a script to run your executable: (the #'s denote optional comment lines)
# define the home directory (this is done automatically on Pleiades)
setenv HOME /usrxx/home/griduser
# add MATLAB MCR to your LD_LIBRARY_PATH
source ${HOME}/MCRSetup.csh
# add directory with executable to LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH ${HOME}/Executables:${LD_LIBRARY_PATH}
# define variable to point at your executable
setenv MATBIN ${HOME}/Executables/matlabprog

Deploying executables on main LSG grid computer

On the main LSC grid computers (CIT, LHO, LLO), the processing nodes can see (through NFS) the same directories as the head and development nodes. This means that MATLAB executables do not have to be tranferred to the "grid computer". Also, since the installed MATLAB libraries are visible, there is no need to build and deploy a MATLAB Common Runtime (MCR).

1) Create MATLAB setup script

A script is needed to to add the MATLAB libraries to LD_LIBRARY_PATH when running the MATLAB executables. This script can be the same one used when testing your compiled MATLAB.
If you don't already have such a script, create a script with the following:
setenv MATLAB_ROOT /ldcg/matlab_r14_sp2
if ( $?LD_LIBRARY_PATH ) then
    setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386:${LD_LIBRARY_PATH}
else
    setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386
endif
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386/client:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.5.0/lib/i386/native_threads:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/opengl/lib/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/bin/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/os/glnx86:${LD_LIBRARY_PATH}
setenv XAPPLRESDIR ${MATLAB_ROOT}/X11/app-defaults
unsetenv MATLAB
Note that this is in 'reverse' order from the Compiler list to ensure correct order in LD_LIBRARY_PATH. Also, I have added a library (/sys/opengl/lib/glnx86) which previous experience with Compiler 4.2 showed was often necessary. I have provided an example csh script which handles a non-existent LD_LIBRARY_PATH and checks if MATLAB was already added to it.

2) Create script to run MATLAB executable on grid

I have found it easier to use a shell script as the 'executable' under condor. Since you can place the MATLAB compiled executable in directories visible from the condor grid nodes, your script can concentrate on setup concerns. Assuming
a) your home directory is /dso-test/griduser on ldas-grid.ligo-*.caltech.edu
b) your MATLAB exectuable is named 'matlabprog' and is in directory /dso-test/griduser/Executables
c) you have put the MatlabSetup.csh script in your home directory
then the following is needed in a script to run your executable: (the #'s denote optional comment lines)
# define the home directory (this is not set automatically)
#  for poorly-understood reasons, MATLAB needs HOME defined.
setenv HOME /dso-test/griduser
# add MATLAB MCR to your LD_LIBRARY_PATH
source ${HOME}/MatlabSetup.csh
# define ARCH to correct for a bug in ghostscript calls under MATLAB executables
# (this is defined within interactive MATLAB, but not when using the libraries)
setenv ARCH glnx86
# add directory with executable to LD_LIBRARY_PATH
setenv LD_LIBRARY_PATH ${HOME}/Executables:${LD_LIBRARY_PATH}
# define variable to point at your executable
setenv MATBIN ${HOME}/Executables/matlabprog


Keith Thorne
Last modified: Mon May 2 2005