MATLAB is a technical computing environment for high-performance numeric computation and visualization. MATLAB integrates numerical analysis, matrix computation, signal processing, and graphics in an easy-to-use environment where problems and solutions are expressed just as they are written mathematically--without traditional programming.
Availability and Restrictions
Versions
MATLAB is available on Pitzer and Owens Clusters. The versions currently available at OSC are:
Version | Owens | Pitzer | Notes |
---|---|---|---|
2015b | X | ||
2016b | X | ||
2017a | X | ||
2018a | X | X | |
2018b | X | X | |
2019a | X | ||
2019b | X | X | |
2020a | X* | X* |
You can use module spider matlab
to view available modules for a given machine. Feel free to contact OSC Help if you need other versions for your work.
Access: Academic Users Only (non-commercial, non-government)
Any academic users at OSC can use Matlab. All users must be added to the license server before using MATLAB. Please contact OSC Help to be granted access.
Publisher/Vendor/Repository and License Type
MathWorks, Commercial (University site license)
Usage
Usage on Owens
Set-up
module load matlab
. For a list of all available MATLAB versions and the format expected, type: module spider matlab
. To select a particular software version, use module load matlab/version
. For example, use module load matlab/r2015b
to load MATLAB version r2015b. Running MATLAB
The following command will start an interactive, command line version of MATLAB:
matlab -nodisplayIf you are able to use X-11 forwarding and have enabled it in your SSH client software preferences, you can run MATLAB using the GUI by typing the command
matlab
. For more information about the matlab command usage, type matlab –h
for a complete list of command line options.
The commands listed above will run MATLAB on the login node you are connected to. As the login node is a shared resource, running scripts that require significant computational resources will impact the usability of the cluster for others. As such, you should not use interactive MATLAB sessions on the login node for any significant computation. If your MATLAB script requires significant time, CPU power, or memory, you should run your code via the batch system.
Batch Usage
When you log into owens.osc.edu you are actually logged into a Linux box referred to as the login node. To gain access to the multiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request multiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info.
Interactive Batch Session
For an interactive batch session using the command line version of MATLAB, one can run the following command:sinteractive -A <project-account> -N 1 -n 28 -t 00:20:00
which requests one whole node with 28 cores ( -N 1 -n 28
), for a walltime of 20 minutes ( -t 00:20:00
). Here you can run MATLAB interactively by loading the MATLAB module and running MATLAB with the options of your choice as described above. You may adjust the numbers per your need.
Parallel Processing in MATLAB
MATLAB supports implicit multithreading on a single node.
Multithreading
Multithreading allows some functions in MATLAB to distribute the work load between cores of the node that your job is running on. By default, all of the current versions of MATLAB available on the OSC clusters have multithreading enabled.
The system will run as many threads as there are cores on the nodes requested.
Multithreading increases the speed of some linear algebra routines, but if you would like to disable multithreading you may include the option " -singleCompThread
" when running MATLAB. An example is given below:
#!/bin/bash #SBATCH --job-name disable_multithreading #SBATCH --time=00:10:00 #SBATCH --nodes=1 --ntasks-per-node=28 #SBATCH --account=<project-account> module load matlab matlab -singleCompThread -nodisplay -nodesktop < hello.m # end of example file
Usage on Pitzer
Set-up
module load matlab
.Running MATLAB
The following command will start an interactive, command line version of MATLAB:
matlab -nodisplayIf you are able to use X-11 forwarding and have enabled it in your SSH client software preferences, you can run MATLAB using the GUI by typing the command
matlab
. For more information about the matlab command usage, type matlab –h
for a complete list of command line options.
The commands listed above will run MATLAB on the login node you are connected to. As the login node is a shared resource, running scripts that require significant computational resources will impact the usability of the cluster for others. As such, you should not use interactive MATLAB sessions on the login node for any significant computation. If your MATLAB script requires significant time, CPU power, or memory, you should run your code via the batch system.
Batch Usage
When you log into pitzer.osc.edu you are actually logged into a Linux box referred to as the login node. To gain access to the multiple processors in the computing environment, you must submit your job to the batch system for execution. Batch jobs can request multiple nodes/cores and compute time up to the limits of the OSC systems. Refer to Queues and Reservations and Batch Limit Rules for more info.
Interactive Batch Session
For an interactive batch session using the command line version of MATLAB, one can run the following command:sinteractive -A <project-account> -N 1 -n 40 -t 00:20:00
which requests one whole node with 40 cores ( -N 1 -n 40
), for a walltime of 20 minutes ( -t 00:20:00
). Here you can run MATLAB interactively by loading the MATLAB module and running MATLAB with the options of your choice as described above. You may adjust the numbers per your need.
Parallel Processing in MATLAB
MATLAB supports implicit multithreading on a single node.
Multithreading
Multithreading allows some functions in MATLAB to distribute the work load between cores of the node that your job is running on. By default, all of the current versions of MATLAB available on the OSC clusters have multithreading enabled.
The system will run as many threads as there are cores on the nodes requested.
Multithreading increases the speed of some linear algebra routines, but if you would like to disable multithreading you may include the option " -singleCompThread
" when running MATLAB. An example is given below:
#!/bin/bash #SBATCH --job-name disable_multithreading #SBATCH --time=00:10:00 #SBATCH --nodes=1 --ntasks-per-node=40 #SBATCH --account=<project-account> module load matlab matlab -singleCompThread -nodisplay -nodesktop < hello.m # end of example file
Concurrent jobs on OSC clusters
When you run multiple jobs concurrently, each job will try to access your preference files at the same time. It may create a race condition issue and may cause a negative impact on the system and the failure of your jobs. In order to avoid this issue, please add the following in your job script:
export MATLAB_PREFDIR=$TMPDIR
It will reset the preference directory to the local temporary directory, $TMPDIR
. If you wish to start your Matlab job with the preference files you already have, add the following before you change MATLAB_PREFDIR
.
cp -a ~/.matlab/{matlab version}/* $TMPDIR/
If you use matlab/r2020a
, your matlab version is "R2020a".
MATLAB with a GPU
A GPU can be utilized for MATLAB. You can acquire a GPU by
#SBATCH --gpus-per-node=1
for Owens, or Pitzer. For more detail, please read here.
You can check the GPU assigned to you using:
gpuDeviceCount # show how many GPUs you have gpuDevice # show the details of the GPU
You can replace an array to gpuArray, for example:
A = gpuArray(A)
where A is a regular MATLAB array. This transfers the array data to the GPU memory. Then, you can use the gpuArray variable in GPU supported built-in functions. You can find the full list of GPU supported built-in functions from here. For more information about GPU programming for MATLAB, please read "GPU Computing" from Mathworks.
Toolboxes and Features
OSC's current licenses support the following MATLAB toolboxes and features (please contact OSC Help for license-specific questions):
Polyspace Bug Finder PolySpace_Bug_Finder_Engine Aerospace_Blockset Aerospace_Toolbox Antenna_Toolbox Audio_System_Toolbox Automated_Driving_Toolbox Bioinformatics_Toolbox Communications System Toolbox Computer Vision System Toolbox Control System Toolbox Curve_Fitting_Toolbox DSP System Toolbox Data Acquisition Toolbox Database_Toolbox Datafeed_Toolbox Econometrics_Toolbox RTW_Embedded_Coder Filter_Design_HDL_Coder Financial Instruments Toolbox Financial_Toolbox Fixed_Point_Toolbox Fuzzy Logic Toolbox Global Optimization Toolbox Simulink_HDL_Coder EDA_Simulator_Link Image_Acquisition_Toolbox Image Processing Toolbox Instrument Control Toolbox LTE System Toolbox MATLAB_Coder MATLAB_Builder_for_Java Compiler MATLAB Report Generator Mapping Toolbox Model Predictive Control Toolbox Model-Based Calibration Toolbox Neural_Network_Toolbox OPC_Toolbox Optimization_Toolbox Distrib_Computing_Toolbox (Parallel Computing Toolbox) Partial Differential Equation Toolbox Phased_Array_System_Toolbox Polyspace Code Prover Powertrain_Blockset RF_Blockset RF_Toolbox Risk_Management_Toolbox Robotics_System_Toolbox Robust Control Toolbox Signal Processing Toolbox SimBiology SimEvents Simscape Driveline Simscape Electronics Simscape Fluids Simscape Multibody Simscape Power Systems Simscape Virtual_Reality_Toolbox Simulink_Code_Inspector Real-Time_Workshop Simulink_Control_Design Simulink Design Optimization Simulink_Design_Verifier Simulink Desktop Real-Time Simulink_PLC_Coder XPC_Target Simulink Report Generator Simulink_Test Simulink Verification and Validation Excel_Link Stateflow Statistics and Machine Learning Toolbox Symbolic Math Toolbox System Identification Toolbox Trading_Toolbox Vehicle_Network_Toolbox Vision_HDL_Toolbox WLAN_System_Toolbox Wavelet_Toolbox
See this page if you need to install additional toolbox by yourself.
Further Reading
Official PDF documentation can be obtained from the MathWorks Website.