Deploying MATLAB Executables with Release R2008a
Deploying MATLAB Executables under MATLAB
R2008a
Assuming you have figured out how to compile MATLAB, the following shows
you how to deploy MATLAB executables for release R2008a on LSC grid computers, and
the Tier 2 centers at Atlas and UWM.
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 AEI's Atlas and UWM's Nemo) 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 (Atlas,UWM) or
Deploying executables on main LSC grids
Deploying executables on stand-alone grids (Atlas,UWM)
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 Atlas at AEI-Hanover and Nemo at UWM.
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). On the Atlas cluster in June, 2008,
the MCR is installed at /home/thorne/MCR/glnx86/v78 (32-bit) and /home/thorne/MCR/glnxa64/v78 (64-bit)
On the Nemo cluster, the MCR would be installed at /home/kthorne/MCR/glnx86/v78 (32-bit) and /home/kthorne/MCR/glnxa64/v78 (64-bit).
2) Get MCR Installer file (MCRInstaller.bin)
The procedure for getting the MCR Installer file has changed since R2007a. Instead
of running the buildmcr command within MATLAB, we get the self-extracting
executable MCRInstaller.bin from a directory in the MATLAB libraries.
The 32-bit glnx86 installer is stored at >MATLAB TOP DIRECTORY</toolbox/compiler/deploy/glnxa64.
The installer also requires a GUI using a remote X-windows session.
3) Transfer and install on Grid computer (**sys-admins only**)
In the following, it is assumed that you can access the grid computer using grid-enabled
ssh and sftp. For this example, I will transfer files from the CIT system to the UWM cluster.
A) Access the grid computer head node with 'sftp' and create a directory for the MCR installer
files. You will note that we create version-specific directories. This is because the installer
file always has the same name, and we want to keep them straight prior to installation.
[thorne@ldas-pcdev1 ~]$ cd /ldcg/matlab_r2008a/toolbox/compiler/deploy/glnxa64/
[thorne@ldas-pcdev1 glnxa64]$ ls
MCRInstaller.bin extractCTF unzip
[thorne@ldas-pcdev1 glnxa64]$ sftp hydra.phys.uwm.edu
Connecting to hydra.phys.uwm.edu...
sftp> mkdir MCR
sftp> cd MCR
sftp> mkdir R2008a
sftp> mkdir R2008a/glnxa64
sftp> cd R2008a/glnxa64
B) Copy the MCRInstaller.bin for v7.8 to the grid computer and quit sftp. Here
I am copying all the files, which include 'extractCTF' and 'unzip'. For
basic installation, only MCRInstaller.bin is needed.
sftp> put *
Uploading MCRInstaller.bin to /home/kthorne/MCR/R2008a/glnxa64/MCRInstaller.bin
MCRInstaller.bin 100% 281MB 775.4KB/s 06:11
Uploading extractCTF to /home/kthorne/MCR/R2008a/glnxa64/extractCTF
extractCTF 100% 7200 7.0KB/s 00:00
Uploading unzip to /home/kthorne/MCR/R2008a/glnxa64/unzip
unzip 100% 112KB 112.2KB/s 00:00
sftp> quit
[thorne@ldas-pcdev1 glnxa64]$
This takes care of the 64-bit version. We can repeat this for the 32-bit version (glnx86).
The two versions can then be installed in the same directory so both 64 and 32 bit versions
are available for users.
C) Access the grid computer head node with 'ssh' to install this MCR on the grid computer.
In their infinite wisdom, Mathworks now makes the default installation using a GUI.
However, a console version is available using a `-console' switch (and recommended
here for remote Linux installs).
Here we start with an example installation of the 32-bit version. Note that we
install this into a 32-bit specific directory. This is to avoid conflict/overwrites
between the 32-bit and 64-bit MCR installations. The 64.bit install is the same
except for the destination folder
[thorne@auriga ~]$ ssh hydra.phys.uwm.edu
------------------------------------------------------------------------------
Welcome to Nemo at UWM
[kthorne@hydra ~]$ cd MCR
[kthorne@hydra ~]$ mkdir glnx86
[kthorne@hydra ~]$ R2008a/glnx86/MCRInstaller.bin -console
Initializing InstallShield Wizard........
Launching InstallShield Wizard........
-------------------------------------------------------------------------------
MATLAB(R) Compiler Runtime 7.8 - InstallShield Wizard
Welcome to the InstallShield Wizard for MATLAB(R) Compiler Runtime 7.8
The InstallShield Wizard will install MATLAB(R) Compiler Runtime 7.8 on your
computer.
To continue, choose Next.
MATLAB(R) Compiler Runtime 7.8
The MathWorks
http://www.mathworks.com
Press 1 for Next, 3 to Cancel or 5 to Redisplay [1]
-------------------------------------------------------------------------------
MATLAB(R) Compiler Runtime 7.8 - InstallShield Wizard
MATLAB(R) Compiler Runtime 7.8 Install Location
Please specify a directory or press Enter to accept the default directory.
Destination Directory [/opt/MATLAB/MATLAB_Component_Runtime] /home/thorne/MCR/glnx86
Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1]
-------------------------------------------------------------------------------
MATLAB(R) Compiler Runtime 7.8 - InstallShield Wizard
MATLAB(R) Compiler Runtime 7.8 will be installed in the following location:
/home/thorne/MCR/glnx86
with the following features:
MATLAB Compiler Runtime
for a total size:
491.6 MB
Press 1 for Next, 2 for Previous, 3 to Cancel or 5 to Redisplay [1]
-------------------------------------------------------------------------------
MATLAB Component Runtime 7.8 - InstallShield Wizard
Installing MATLAB Component Runtime 7.8. Please wait...
|-----------|-----------|-----------|------------|
0% 25% 50% 75% 100%
||||||||||||||||||||||||||||||||||||||||||||||||||
Creating uninstaller...
Finalizing the Vital Product Data Registry. Please wait...
-------------------------------------------------------------------------------
MATLAB Component Runtime 7.8 - InstallShield Wizard
The InstallShield Wizard has successfully installed MATLAB Component Runtime
7.8. Choose Finish to exit the wizard.
Press 3 to Finish or 5 to Redisplay [3]
** this creates a v78 sub-directory under the MCR/glnx86 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 glnx86 in csh:
# -- the MCR_ROOT location is system specific - Here at UWM
setenv MCR_ROOT /home/kthorne/MCR/glnx86/v78
setenv ARCH glnx86
if ( $?LD_LIBRARY_PATH ) then
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/opengl/lib/glnx86:${LD_LIBRARY_PATH}
else
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/opengl/lib/glnx86
endif
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386/server:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386/native_threads:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/bin/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/os/glnx86:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/run_time/glnx86:${LD_LIBRARY_PATH}
setenv XAPPLRESDIR ${MCR_ROOT}/X11/app-defaults
This setup has some changes from the MathWorks instructions:
- The ARCH environment variable is defined. This is needed to fix a problem in calling Ghostscript
when creating figures in compiled code.
- The bin/glnx86 library is added to LD_LIBRARY_PATH. This catches some dependencies
that can be missed by the compiler
- The sys/opengl/lib/glnx86 library is also added. This again catches some dependencies
missed in the past by the compiler
Here it is for glnxa64 in csh:
# -- the MCR_ROOT location is system specific - Here at UWM
setenv MCR_ROOT /home/kthorne/MCR/glnxa64/v78
setenv ARCH glnxa64
if ( $?LD_LIBRARY_PATH ) then
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/opengl/lib/glnxa64:${LD_LIBRARY_PATH}
else
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/opengl/lib/glnxa64
endif
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/server:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/native_threads:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/bin/glnxa64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/sys/os/glnxa64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MCR_ROOT}/run_time/glnxa64:${LD_LIBRARY_PATH}
setenv XAPPLRESDIR ${MCR_ROOT}/X11/app-defaults
This has additions similar to the glnx86 case.
I have prepared MCR setup scripts (both csh and bash) for the following:
You should be able to modify these as needed.
Transfer this MCR Setup file to the Grid computer using sftp. Here is an example
for UWM.
[thorne@auriga ~]$ sftp hydra.phys.uwm.edu
Connecting to hydra.phys.uwm.edu...
sftp> put MCRSetup_R2008a_glnx86.csh
5) Transfer MATLAB executable to Grid computer
You must move the compiled executable (and the separate CTF file if it is not embedded)
to the Grid computer. If doing it statically and assuming 'matlabprog' is the
executable, then use
sftp> mkdir Exectuables
sftp> cd Executables
sftp> put matlabprog
sftp> put matlabprog.ctf
sftp> chmod 755 matlabprog
sftp> quit
An alternative is to transfer these within the Condor submission, but remember
that you still need to do the 'chmod 755' on the transferred MATLAB executable.
6) 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 /usr1/home/griduser
b) your MATLAB exectuable is named 'matlabprog' and is in sub-directory 'Executables'
c) you have put the MCRSetup_x.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 /home/griduser
# add MATLAB MCR to your LD_LIBRARY_PATH
source ${HOME}/MCRSetup_R2008a_glnx86.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
# run your executable
${MATBIN} ..command-line arguments..
Deploying executables on LSG grid computers
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) Make sure HOME and PATH will be defined for grid jobs
When MATLAB or the MCR expands an executable, it wants to save a preferences file to
the location ${HOME}/.matlab/mcr_v78. If HOME is not a defined environment variable,
it will fail. Also, it requires that the LD_LIBRARY_PATH and PATH environment variables
be defined.
One way to ensure this with Condor grid jobs is to include 'getenv = True' in the condor
submission. Add the following in your Condor submission script
getenv = True
2) Fix your startup.m file to running executables
When running a stand-alone build on a system where the grid nodes can see the
development disks (such as CIT,LLO,LHO), you need to make sure it sees
the local encrypted m-files instead of ones from your CVS sandbox.
We wrap any addpath
commands (which let us see the CVS sandbox files) with a conditional to
prevent their use when running an
executable. For Release 2008a, the
version('-release') function returns
a text string 2008a that
can not be converted to a numeric value. This complicates things if you wish to preserve backward compatibility
with Release 13. A complete syntax of the startup.m file should now be:
verNum = str2num(version('-release'));
if(~isempty(verNum))
verOld = verNum < 14;
else
verOld = false;
end
if( (verOld == true) || (~isdeployed))
...
addpath commands
...
end
clear verNum;
clear verOld;
The startup.m file should be in your ~/matlab
directory.
**NOTE** You may have already done this if following the compilation info page
3A) Create 32-bit MATLAB setup script
If using 32-bit executables, a script is needed to to add the 32-bit 'glnx86' 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_R2008a
setenv ARCH glnx86
#
if ( $?LD_LIBRARY_PATH ) then
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/opengl/lib/glnx86:${LD_LIBRARY_PATH}
else
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/opengl/lib/glnx86
endif
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386/server:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnx86/jre1.6.0/lib/i386/native_threads:${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.1 showed was often necessary.
I have provided examples in
csh (MatlabSetup_R2008a_glnx86.csh) and
bash (MatlabSetup_R2008a_glnx86.sh) that handle
a non-existent LD_LIBRARY_PATH and checks if MATLAB was already added to it. They are the same as
the ones used in testing executables on the development node.
3B) Create 64-bit MATLAB setup script
If using 64-bit executables at CIT, a script is needed to to add the 64-bit 'glnxa64' 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_R2008a
setenv ARCH glnxa64
#
if ( $?LD_LIBRARY_PATH ) then
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/opengl/lib/glnxa64:${LD_LIBRARY_PATH}
else
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/opengl/lib/glnxa64
endif
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/server:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/java/jre/glnxa64/jre1.6.0/lib/amd64/native_threads:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/extern/lib/glnxa64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/sys/os/glnxa64:${LD_LIBRARY_PATH}
setenv LD_LIBRARY_PATH ${MATLAB_ROOT}/bin/glnxa64:${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. This setup does not match that in the MATLAB documentation.
I have added a library (/sys/opengl/lib/glnx86) which previous experience
with Compiler 4.1 showed was often necessary.
I have provided examples in
csh (MatlabSetup_R2008a_glnxa64.csh) and
bash (MatlabSetup_R2008a_glnxa64.sh) that handle
a non-existent LD_LIBRARY_PATH and checks if MATLAB was already added to it.
4A) Create script to run 32-bit 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 /archive/home/griduser on ldas-grid.ligo-*.caltech.edu
b) your MATLAB exectuable is named 'matlabprog' and is in directory /archive/home/griduser/Executables
c) you have put the MatlabSetup_R2008a_glnx86.csh script in your home directory
then the following is needed in a script to run your 32-bit executable:
(the #'s denote optional comment lines)
# define the home directory (this is not set automatically)
# MATLAB needs HOME defined.
setenv HOME /archive/home/griduser
# add 32-bit MATLAB MCR to your LD_LIBRARY_PATH
source ${HOME}/MatlabSetup_R2008a_glnx86.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
# run your executable
${MATBIN} ..command-line arguments..
4B) Create script to run 64-bit 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 /archive/home/griduser on ldas-grid.ligo.caltech.edu
b) your MATLAB exectuable is named 'matlabprog' and is in directory /archive/home/griduser/Executables
c) you have put the MatlabSetup_R2008a_glnxa64.csh script in your home directory
then the following is needed in a script to run your 64-bit executable:
(the #'s denote optional comment lines)
# define the home directory (this is not set automatically)
# MATLAB needs HOME defined.
setenv HOME /archive/home/griduser
# add 64-bit MATLAB MCR to your LD_LIBRARY_PATH
source ${HOME}/MatlabSetup_R2008a_glnxa64.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
# run your executable
${MATBIN} ..command-line arguments..
Keith Thorne t h o r n e @ g r a v i t y . p s u . e d u
Last modified: Fri, June 13, 2008