MATLAB¶
Description¶
MATLAB is a high-level language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran.
Environment Modules¶
Run module spider matlab to find out what environment modules are available for this application.
Environment Variables¶
- HPC_MATLAB_DIR - installation directory
- HPC_MATLAB_BIN - executable directory
Additional Usage Information¶
MATLAB Use Policy¶
Note
Make an effort to compile MATLAB scripts. Many toolkit licenses are almost always checked out.
- Do not run MATLAB or compiled MATLAB executables interactively on the login servers. Long running (more than 10 minutes) MATLAB scripts must be compiled and submitted to the scheduler.
- Do not idle MATLAB or import and not use MATLAB toolkits. The number of UF licenses is limited and preventing other users from loading MATLAB or toolkits while not actively using them yourself may result in the suspension of your HiPerGator account.
Toolbox Licenses¶
UFIT Research Computing does not purchase software licenses. All MATLAB licenses (including the compiler) come from the campus-wide licensing server. For this reason, it is sometimes difficult to load a particular toolkit in high demand 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 MATLAB toolkit licenses for your personal or group use. We can set up a custom MATLAB install for your group on HiPerGator, which will restrict the configured license to your group.
The complete list of MATLAB toolboxes can be found on the MATLAB Add-On Availability website.
We provide a matlab_show_license_use command in the ufrc module that can be used to display or search the
toolkits available via the UF MATLAB licensing server, and report their current usage in several formats.
$ matlab_show_license_use -h
usage: matlab_show_license_use.py [-h] [-S KEYWORD | -C | -R] [-o FORMAT] [-v]
MATLAB license usage monitor
options:
-h, --help show this help message and exit
-S, --search KEYWORD Search for a toolbox with a keyword in the name (case-insensitive).
-C, --counts Show MATLAB and toolbox license use counts.
-R, --raw Show raw/full MATLAB and toolbox license use. Does not support --output csv or json.
-o, --output FORMAT Output format: human (default), csv, or json. Not supported with --raw.
-v, --verbose Show user details. Combinable with --counts or --search.
Compiling MATLAB Programs¶
We strongly encourage you to compile MATLAB programs via the MATLAB compiler and running that code on HiPerGator as standalone executables instead of running the full MATLAB GUI interface. Running a compiled MATLAB program allows you to execute your code without consuming a MATLAB license during runtime. Instead of the full MATLAB software, it utilizes the free MATLAB Runtime (MCR).
To compile and run MATLAB programs:
- [ ] Start an interactive SLURM session. See the Development and Testing article to learn how to start an interactive developmental session on HiPerGator.
-
[ ] Set up your MATLAB environment so that the libraries needed by the compiler can be found.
Note: Choose a matlab module version for which there is a matching MATLAB Runtime (MCR) version. See below.module load matlab/<version> -
[ ] Compile your MATLAB program (.m) files using the MATLAB compiler.
Note: The "-R -singleCompThread" option on the mcc command line will result in a single-threaded executable. By default, multithreading is enabled in executables produced by mcc. 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 "-R -singleCompThread" and generate a single-threaded executable.mcc -R -singleCompThread -m my_prog.m -
[ ] Locate Your Compiled Files. When you compile a MATLAB script (e.g., using
mcc -R -singleCompThread -m my_prog.m), the compiler generates two critical files you need to run the application:- [ ] The binary executable (e.g., my_prog)
- [ ] The shell wrapper script (e.g., run_my_prog.sh)
-
[ ] Determine the MATLAB Runtime (MCR) Path. The shell wrapper needs to know exactly where the MATLAB Runtime is installed.
$ ml mcr/2024b $ echo $MCROOT /apps/matlab/mcr/2024b/R2024b/ -
[ ] Create a Batch Submission Script
Note: Either a#!/bin/bash #SBATCH --job-name=matlab_compiled #SBATCH --output=output_%j.txt #SBATCH --error=error_%j.txt #SBATCH --ntasks=1 #SBATCH --cpus-per-task=4 #SBATCH --mem=16G #SBATCH --time=02:00:00 # 1. Load the MCR module that matches the exact MATLAB version used to compile the code: module load mcr/2024b # 2. Run the wrapper script. # Syntax: ./run_<program>.sh <path_to_mcr_root> [arguments] ./run_myscript.sh /apps/matlab/mcr/2024b/R2024b/ arg1 arg2mcr/<version>ormatlab/<version>environmental module can be loaded in your batch script. Both will allow your compiled MATLAB executable to find the appropriate dynamically loaded libraries. We recommend loading the MATLAB Runtime (MCR) module as it does not consume a MATLAB license. -
[ ] submit batch script
MATLAB Runtime (MCR)¶
We provide both matlab and mcr environment modules. The latter only contains the MATLAB compiler runtime, which can be used to run compiled MATLAB applications or components.
- No License Needed: The MATLAB Runtime is freely redistributable and does not consume or require a paid MATLAB license.
- Exact Version Matching: The MATLAB Runtime version must strictly match the release version of MATLAB used to compile the application (for example, an R2024a executable requires the R2024a MATLAB Runtime).
- What MCR Contains: It includes the shared libraries needed to execute encrypted MATLAB code, acting essentially as the engine of MATLAB without the desktop GUI.
Categories¶
math, language