Computational Science Community Wiki

MATLAB and Condor

This describes how to create a MATLAB stand-alone executable and submit it to a Condor pool. MATLAB stand-alone executables are very useful because they run without using a licence.

Note:

Other Resources

Summary (for Linux)

  1. Write a version of your MATLAB .m file that treats all input arguments as strings, e.g. using the MATLAB function str2num.

  2. Compile a standalone MATLAB executable by:
    1. Starting MATLAB (note issues with multi-threading described below).
    2. Enter mcc -m -R -nojvm -R -singleCompThread <filename>.m to create files <filename> and run_<filename>.sh which are required on the Condor compute node to run the executable.

      • <filename> is the compiled executable

      • run_<filename>.sh is a script which when executed sets up the necessary environment variables before launching <filename>. The first argument to run_<filename>.sh should be the MATLAB path, additional arguments are passed to <filename>.

      • Omit the -R -singleCompThread for a multi-threaded version.

      • Various other files are also created which are not required.
  3. Create a new directory and copy <filename> and run_<filename>.sh to it.

  4. In the new directory write your Condor submission script which contains:
    1. executable = run_<filename>.sh (since run_<filename>.sh must be executed first)

    2. arguments = <MATLAB_path> <MATLAB_executable_arguments> (i.e. first argument is MATLAB path)

    3. universe = vanilla

    4. transfer_input_files = <filename> (to tell Condor to transfer <filename> to the remote node).

  5. Submit to Condor

Switching off multi-threading

Additional information can be found here and here.

mcc licence

Using mcc from the command line

Problems you might encounter

Setting environment for Condor

See links under the High Throughput Computing section here for more information.

MATLAB_PREFDIR

MATLAB stand alone executables have been known to fail periodically, with messages like

Failed copying '/var/condor-6.8.8/execute/dir_15370/generate_seeds_mcr/generate_seeds_219EABB7AC26BF192B2A6A9EDE741EE2/matlab.prf' to '/mnt/nfs_R1L0/mcbicjb2/.matlab/mcr_v77/generate_seeds_219EABB7AC26BF192B2A6A9EDE741EE2/matlab.prf'. Should have written 671 bytes to destination file, but actually wrote 0 bytes

Error initializing preferences required to run the application

This can be avoided by pointing the MATLAB_PREFDIR variable to a non-existent directory, e.g.

export MATLAB_PREFDIR=/tmp/emptydir

This solution is described here.

MCR_CACHE_ROOT

MATLAB stand alone executables may fail with Could not access the MCR component cache. error message because MATLAB is unable to access the MCE cache directory, which it expects to be in your home directory.

This can be avoided by pointing the MCR_CACHE_ROOT variable to a non-existent directory, e.g.

export MCR_CACHE_ROOT=/tmp/emptydir

Note: these environment variables can be set from the Condor submit script, i.e. environment = MCR_CACHE_ROOT=/tmp/emptydir;MATLAB_PREFDIR=/tmp/emptydir