Difference between revisions of "Matlab"

From UFRC
Jump to navigation Jump to search
 
(117 intermediate revisions by 8 users not shown)
Line 1: Line 1:
==Installation==
+
__TOC__
Currently matlab is located here:
+
__NOEDITSECTION__
<pre>
+
[[Category:Software]][[Category:Language]][[Category:Math]]
/apps/matlab/bin
+
{|<!--Main settings - REQUIRED-->
</pre>
+
|{{#vardefine:app|matlab}}
==Policy==
+
|{{#vardefine:url|http://www.mathworks.com/}}
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.
+
|{{#vardefine:exe|1}} <!--Present manual instructions for running the software -->
==Compiler==
+
|{{#vardefine:conf|}} <!--Enable config wiki page link - {{#vardefine:conf|1}} = ON/conf|}} = OFF-->
 +
|{{#vardefine:job|1}} <!--Enable job script wiki page link-->
 +
|{{#vardefine:policy|}} <!--Enable policy section -->
 +
|{{#vardefine:testing|}} <!--Enable performance testing/profiling section -->
 +
|{{#vardefine:faq|}} <!--Enable FAQ section -->
 +
|{{#vardefine:citation|}} <!--Enable Reference/Citation section -->
 +
|}
 +
<!-- ########  Template Body ######## -->
 +
<!--Description-->
 +
{{#if: {{#var: url}}|
 +
{{App_Description|app={{#var:app}}|url={{#var:url}}|name={{#var:app}}}}|}}
 +
 
 +
MATLAB is a programming environment for algorithm development, data analysis, visualization, and numerical computation. Using MATLAB, you can solve technical computing problems faster than with traditional programming languages, such as C, C++, and Fortran.
 +
 
 +
You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. For a million engineers and scientists in industry and academia, MATLAB is the language of technical computing.
 +
<!--Modules-->
 +
==Environment Modules==
 +
Run <code>module spider matlab</code> or <code>module spider mcr</code> to find out what environment modules are available for the MatLab GUI and for the Matlab Compiler Runtime. Use matlab for compiling your code and mcr for running it. The mcr does not consume matlab licenses.
 +
 
 +
==Restrictions==
 +
MatLab install on HiPerGator is restricted to the toolboxes available under the UF license. The full list of ineligible toolboxes is on the MATLAB website:
 +
 
 +
[https://www.mathworks.com/support/requirements/product-requirements-platform-availability-list.html MATLAB Add-On Availability]
 +
 
 +
Run <code>matlab_show_license_use</code> after loading a matlab module to see what licenses are available and how many are in use.
  
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.
+
==System Variables==
 +
* HPC_{{uc:{{#var:app}}}}_DIR - installation directory
 +
<!--Additional-->
 +
{{#if: {{#var: conf}}|==Configuration==
 +
See the [[{{PAGENAME}}_Configuration]] page for {{#var: app}} configuration details.
 +
|}}
 +
{{#if: {{#var: policy}}|==Usage Policy==
 +
WRITE USAGE POLICY HERE (perhaps templates for a couple of main licensing schemes can be used)
 +
|}}
 +
{{#if: {{#var: testing}}|==Performance==
 +
WRITE PERFORMANCE TESTING RESULTS HERE|}}
 +
{{#if: {{#var: faq}}|==FAQ==
 +
*'''Q:''' **'''A:'''
 +
|}}
 +
{{#if: {{#var: citation}}|==Citation==
 +
If you publish research that uses {{#var: app}} you have to cite it as follows:
 +
X. Yang, K. Dorman and S. Aluru, “Reptile: Representative tiling for short read error correction”, Bioinformatics, 26(20), 2526-2533, 2010.
 +
|}}
 +
==Policies==
 +
# You may not run MatLab nor compiled MatLab executables interactively on the login servers.
 +
# Long running (more than 30 minutes) MatLab jobs need to be in compiled form and must be submitted to the batch system.
 +
# UF Research Computing has no budget for application software and licensing. All MatLab licenses (including the compiler) come from, and are shared with, all of UF campus. For this reason it is sometimes difficult to obtain a license or MatLab may take a long time to start. 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.
  
First, log into one of the test nodes; these are named test03, test04, and test05.
+
==Available components==
 +
See the [[Matlab add-ons]] for a full list of licensed Matlab components.
  
Then you need to setup your environment so that the proper libraries are available for use by Matlab:
+
==Compiling MatLab Programs==
 +
MatLab programs must be compiled via the MatLab compiler before they can be run in batch mode on HiPerGator.
  
$ export LD_LIBRARY_PATH=/apps/matlab/bin/glnxa64:/apps/matlab/sys/os/glnxa64
+
In order to compile MatLab programs you should
$ export PATH=${PATH}:/apps/matlab/bin
 
  
'''These environment settings will also need to be in place for when you run the executables that are produced in this method.
+
# See [[Development and Testing]] page to learn how to get an interactive developmental session on HiPerGator under SLURM.
'''
+
# Set up your environment so that the libraries needed by the compiler can be found.
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.
+
module load matlab
 +
'''Note:''' The module load command should be included in your batch submission script as well since your compiled matlab executable will also need to find the appropriate dynamically loaded libraries.
 +
# Compile your matlab program (.m) files using the MatLab compiler ([[mcc]]).
 +
mcc -R -singleCompThread -m some_prog.m
  
 
===Example===
 
===Example===
Let us say that we have a program called houdin.m, which looks like this:
+
Let us say that we have a program such as that below in a source file named houdini.m
 
<pre>
 
<pre>
 
function [m,t] = houdini();
 
function [m,t] = houdini();
Line 36: Line 85:
 
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.
 
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.
 
<pre>
 
<pre>
$ mkdir tmp
+
mkdir tmp
$ cd tmp
+
cd tmp
$ cp ../houdini.m .
+
cp ../houdini.m .
$ ls
+
module load matlab
houdini.m
+
mcc -R -singleCompThread -m houdini.m  
$ export LD_LIBRARY_PATH=/apps/matlab/bin/glnxa64:/apps/matlab/sys/os/glnxa64
+
ls -l
$ 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
 
total 124
 
-rwxr-xr-x  1 root root 12299 Apr  3 10:08 houdini
 
-rwxr-xr-x  1 root root 12299 Apr  3 10:08 houdini
Line 58: Line 102:
 
-rwxr--r--  1 root root  1446 Apr  3 10:08 run_houdini.sh
 
-rwxr--r--  1 root root  1446 Apr  3 10:08 run_houdini.sh
 
</pre>
 
</pre>
So there we have it. A binary executable '''houdini''' has been produced.
+
The MatLab executable '''houdini''' has been generated, and can be run by typing ./houdini, or by putting that command in a batch submission script.
 +
 
 +
'''Note:'''  The "<code>-R -singleCompThread</code>" 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.
 
----
 
----
For more information, documentation for the Matlab Compiler can be viewed at the [http://www.mathworks.com/access/helpdesk/help/toolbox/compiler Matlab Website].
+
[http://www.mathworks.com/access/helpdesk/help/toolbox/compiler MatLab Compiler Documentation] can be found on the MatLab Website.
 +
 
 +
==MATLAB GUI use on HiPerGator==
 +
 
 +
If you must use the Graphical User Interface for MatLab pick one of the available approaches described in the [[GUI_Programs|GUI Programs]] documentation depending on your need for hardware acceleration, convenience, and remote GUI performance considerations.
 +
 
 +
==MATLAB online training==
 +
Please see the Pre-recorded [https://training.it.ufl.edu/training/items/running-matlab-on-hipergator.html MATLAB on HiPerGator Training session] for information on using MATLAB on HiPerGator.
 +
 
 +
Mathworks also has a number of free [https://www.mathworks.com/services/training.html online training resources].
 +
 
  
==Frequently Asked Questions==
+
==Compiled DLL==
 +
If you have compiled a MatLab 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 Command Path==
 +
To set a command path in your MatLab program, should add the following code.
 
<pre>
 
<pre>
Dear Sirs,
+
path(path, '/path/to/matlab/binaries')
 +
</pre>
 +
This will add the specified directory to the matlab search path. For more information see the [http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/path.html&http://www.google.com/search?hl=en&q=matlab+set+path&btnG=Google+Search&aq=f&oq= Matlab] web site.
 +
 
 +
==Known Issues==
 +
===No Licenses Available===
 +
You may run into an error when using the MatLab compiler such as
 +
 
 +
'''Licensed number of users already reached.'''
 +
 
 +
If so, the number of licenses available for the MatLab compiler has been exceeded. There are only two shared among the entire university so you should expect to see this problem from time to time if you use the MatLab compiler frequently. If the problem persists for more than a few hours, please open a [https://support.rc.ufl.edu support request].
 +
 
 +
===MCR_CACHE_ROOT Directory===
 +
'''Could not access the MCR component cache'''
  
I have a basic question about what can be run on the cluster. I have a
+
This error message means that MatLab is not able to access the MCR cache directory. When you load the MATLAB module, MCR_CACHE_ROOT is set for you, and you should not encounter this error. If you do, please open a [https://support.rc.ufl.edu support request]. For batch jobs, module load matlab makes use of the $TMPDIR variable and MCR_CACHE_ROOT is set to $TMPDIR/mcr_cache. For non-batch jobs, MCR_CACHE_ROOT is set to /scratch/local/$USER/mcr_cache
standalone C application file generated by the Matlab compiler. Is it
+
   
  possible to run it (after porting/copying the required libraries) as an
+
===Interactive Use===
external application on a particular node of the cluster. This is
+
See the GUI section above for information on running the MATLAB GUI on HiPerGator.
  because it is not possible for me to compile the C source files on the
 
cluster itself?
 
</pre> 
 
OK... from what I gather here, I think you have the following:
 
  
# A compiled executable, most likely in linux x86 format.
+
Some Windows users running Xming have reported problems with MATLAB becoming unresponsive, especially after saving a new file. If you run into this problem, we suggest using an alternate X11 server, such as [http://mobaxterm.mobatek.net/ MobaXterm]. Please open a [http://support.rc.ufl.edu support request] if you continue to experience problems.
#: 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.
+
 
# Possibly the source code.
+
===Older Versions===
#: 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.
+
In order to use older versions of Matlab that are installed on the cluster, you can list them via the following command:
===Where is the Distributed Computing Toolbox?===
+
<pre>
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.
+
$ module spider matlab
===Compiled DLL===
+
</pre>
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.
+
If you were to see that an older version of matlab is available, such as version r2012a, you would then load the appropriate module for that version:
 +
<pre>
 +
$ module load matlab/2012a
 +
</pre>

Latest revision as of 18:24, 18 August 2022

Description

matlab website  

MATLAB is a programming environment for algorithm development, data analysis, visualization, and numerical computation. Using MATLAB, you can solve technical computing problems faster than with traditional programming languages, such as C, C++, and Fortran.

You can use MATLAB in a wide range of applications, including signal and image processing, communications, control design, test and measurement, financial modeling and analysis, and computational biology. For a million engineers and scientists in industry and academia, MATLAB is the language of technical computing.

Environment Modules

Run module spider matlab or module spider mcr to find out what environment modules are available for the MatLab GUI and for the Matlab Compiler Runtime. Use matlab for compiling your code and mcr for running it. The mcr does not consume matlab licenses.

Restrictions

MatLab install on HiPerGator is restricted to the toolboxes available under the UF license. The full list of ineligible toolboxes is on the MATLAB website:

MATLAB Add-On Availability

Run matlab_show_license_use after loading a matlab module to see what licenses are available and how many are in use.

System Variables

  • HPC_MATLAB_DIR - installation directory



Policies

  1. You may not run MatLab nor compiled MatLab executables interactively on the login servers.
  2. Long running (more than 30 minutes) MatLab jobs need to be in compiled form and must be submitted to the batch system.
  3. UF Research Computing has no budget for application software and licensing. All MatLab licenses (including the compiler) come from, and are shared with, all of UF campus. For this reason it is sometimes difficult to obtain a license or MatLab may take a long time to start. 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.

Available components

See the Matlab add-ons for a full list of licensed Matlab components.

Compiling MatLab Programs

MatLab programs must be compiled via the MatLab compiler before they can be run in batch mode on HiPerGator.

In order to compile MatLab programs you should

  1. See Development and Testing page to learn how to get an interactive developmental session on HiPerGator under SLURM.
  2. Set up your environment so that the libraries needed by the compiler can be found.
module load matlab

Note: The module load command should be included in your batch submission script as well since your compiled matlab executable will also need to find the appropriate dynamically loaded libraries.

  1. Compile your matlab program (.m) files using the MatLab compiler (mcc).
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.

 mkdir tmp
 cd tmp
 cp ../houdini.m .
 module load matlab
 mcc -R -singleCompThread -m houdini.m 
 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, and can be run by typing ./houdini, or by putting that command in a batch submission script.

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.


MatLab Compiler Documentation can be found on the MatLab Website.

MATLAB GUI use on HiPerGator

If you must use the Graphical User Interface for MatLab pick one of the available approaches described in the GUI Programs documentation depending on your need for hardware acceleration, convenience, and remote GUI performance considerations.

MATLAB online training

Please see the Pre-recorded MATLAB on HiPerGator Training session for information on using MATLAB on HiPerGator.

Mathworks also has a number of free online training resources.


Compiled DLL

If you have compiled a MatLab 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 Command Path

To set a command path in your MatLab program, should add the following code.

path(path, '/path/to/matlab/binaries')

This will add the specified directory to the matlab search path. For more information see the Matlab web site.

Known Issues

No Licenses Available

You may run into an error when using the MatLab compiler such as

Licensed number of users already reached.

If so, the number of licenses available for the MatLab compiler has been exceeded. There are only two shared among the entire university so you should expect to see this problem from time to time if you use the MatLab compiler frequently. If the problem persists for more than a few hours, please open a support request.

MCR_CACHE_ROOT Directory

Could not access the MCR component cache

This error message means that MatLab is not able to access the MCR cache directory. When you load the MATLAB module, MCR_CACHE_ROOT is set for you, and you should not encounter this error. If you do, please open a support request. For batch jobs, module load matlab makes use of the $TMPDIR variable and MCR_CACHE_ROOT is set to $TMPDIR/mcr_cache. For non-batch jobs, MCR_CACHE_ROOT is set to /scratch/local/$USER/mcr_cache

Interactive Use

See the GUI section above for information on running the MATLAB GUI on HiPerGator.

Some Windows users running Xming have reported problems with MATLAB becoming unresponsive, especially after saving a new file. If you run into this problem, we suggest using an alternate X11 server, such as MobaXterm. Please open a support request if you continue to experience problems.

Older Versions

In order to use older versions of Matlab that are installed on the cluster, you can list them via the following command:

$ module spider matlab

If you were to see that an older version of matlab is available, such as version r2012a, you would then load the appropriate module for that version:

$ module load matlab/2012a