Skip to content

CSCfi/csc-env-matlab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

csc-env-matlab

In this repository contains intructions for creating a containerized MATLAB and MATLAB Parallel Server (MPS) installation for Linux with Apptainer. Containerized installation is useful for Linux cluster environments. We need graphical user interface for installing MATLAB, for example, desktop or laptop computer. Currently, there are instructions for installing MATLAB version R2023b.

Installing MATLAB on local computer

License file

We use a network license for the installation. Network license queries the license permissions from a license server. We need a license file (such as license.lic) to connect to the license server with contents as follows:

SERVER <hostname> <host-id> <lmgrd-port>
USE_SERVER

The license file must contain appropriate values for hostname and host ID (MAC address) of the license server and TCP/IP port number of the license manager daemon (lmgrd) on the license server.

Download the MATLAB installer

Go to the downloads page and select the latest version and download matlab the installer for Linux. Then, create the installer directory and move the MATLAB installer to the installer directory and rename it to lowercase of the version string.

# Create the installer directory
mkdir -p installer

# Move and rename the installer
mv ~/Downloads/matlab_R2023b_glnxa64.zip installer/r2023b.zip

Then, create a new subdirectory for the installer version and unarchive the installer files to the directory.

# Create the installer directory for specific version
mkdir -p installer/r2023b

# Unarchive the installer into the directory
unzip installer/r2023b.zip -d installer/r2023b

Creating the MATLAB installation

Create installation directory and install matlab using the graphical installer to the directory.

# Create the installation directory.
mkdir -p matlab/r2023b/build

# Run the installer
./installer/r2023b/install

Supply your login information. During the installation we must set the following options:

  • LICENSING
    • Select appropriate license for the installation.
    • If required, supply the license file. For CSC's academic installations, we can use the license/academic.lic file.
  • DESTINATION
    • Select path to the installation directory.
    • CSC's MATLB interactive installation path is matlab/r2023b/build
    • CSC's MATLB Parallel Server installation path is mps/r2023b/build
  • PRODUCTS
    • Select necessary toolboxes to install.
    • CSC's MATLAB interactive installation requires MATLAB, MATLAB Compiler, MATLAB Compiler SDK, and Parallel Computing Toolbox toolboxes
    • CSC's MATLAB Parallel Server installation requires MATLAB and MATLAB Parallel Server toolboxes
  • OPTIONS
    • Unselect options to create symbolic links and sending information to matlab.
  • CONFIRMATION
    • Confirm the installation.

Building the MATLAB container

We build the container on top of a base container that contains the required dependencies to run MATLAB. Base container definitions are modified from the MathWorks official container images. The MATLAB container definition copies the MATLAB installation to /opt/matlab directory and sets the file permissions such that the installation is available for all users. We can build the MATLAB container as follows:

apptainer build matlab/r2023b/matlab.sif matlab/r2023b/matlab.def

Testing the MATLAB container

We can test the MATLAB container by running the ver function as follows:

apptainer exec matlab/r2023b/matlab.sif matlab -nodisplay -r 'ver; quit;'

Using the MATLAB container with wrapper scripts

We can use the container by creating wrapper scripts that call the MATLAB binaries from the container. Write the following scripts to the matlab file and give it execution permissions chmod u+x matlab.

#!/bin/bash
apptainer exec matlab/r2023b/matlab.sif matlab "$@"

On CSC's Puhti cluster, we can use the apptainer_wrapper which automatically bind mounts the cluster specific directories to the container. You can read about running container in CSC clusters.