software:matlab:mills

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
software:matlab:mills [2017-09-07 16:52] – created sraskarsoftware:matlab:mills [2019-08-29 16:05] (current) – [Matlab script] anita
Line 4: Line 4:
 On Mills, MATLAB projects should be developed using a Desktop installation of MATLAB and then copied to the cluster On Mills, MATLAB projects should be developed using a Desktop installation of MATLAB and then copied to the cluster
 to be run in batch.  Here we to be run in batch.  Here we
-consider an extended MATLAB example involving tow simple MATLAB functions, and two MATLAB scripts to execute+consider an extended MATLAB example involving two simple MATLAB functions, and two MATLAB scripts to execute
 the first function in a loop, and to using the Parallel Toolbox. the first function in a loop, and to using the Parallel Toolbox.
  
 Details on how to run these two scripts in batch are given with the resulting output files.  There is also a Details on how to run these two scripts in batch are given with the resulting output files.  There is also a
-section with UNIX commands you can use to watch your jobs and gather [[#timing and core count]] numbers.  +section with UNIX commands you can use to watch your jobs and gather [[#timings-and-core-count | timing and core count]] numbers.  
 You will need to know how much memory and how many cores you should request for your jobs. You will need to know how much memory and how many cores you should request for your jobs.
  
Line 25: Line 25:
 </note> </note>
  
 +==== Matlab License Information ====
 +
 +Matlab licenses are pushed into consumable (global, per-job) integer complexes in Grid Engine and can be checked using 
 +
 +<code>
 +        qhost -h global -F
 +</code>
 +
 +to list number of unused license seats for each product.
 +
 +Below is an example representing a snapshot of unused licensed seats for Matlab products on the cluster.
 +<code>
 + [traine@mills ~]$ qhost -h global -F
 + HOSTNAME                ARCH         NCPU  LOAD  MEMTOT  MEMUSE  SWAPTO  SWAPUS
 + -------------------------------------------------------------------------------
 + global                  -                                           -
 +     gc:MLM.Compiler=50.000000
 +            gc:MLM.Aerospace_Blockset=1.000000
 +            gc:MLM.RTW_Embedded_Coder=2.000000
 +            gc:MLM.Robust_Toolbox=150.000000
 +            gc:MLM.Aerospace_Toolbox=1.000000
 +            gc:MLM.Identification_Toolbox=50.000000
 +            gc:MLM.XPC_Target=2.000000
 +            gc:MLM.Econometrics_Toolbox=1.000000
 +            gc:MLM.Real-Time_Workshop=2.000000
 +            gc:MLM.Fuzzy_Toolbox=50.000000
 +            gc:MLM.Video_and_Image_Blockset=1.000000
 +            gc:MLM.Neural_Network_Toolbox=50.000000
 +            gc:MLM.Fin_Instruments_Toolbox=1.000000
 +            gc:MLM.Optimization_Toolbox=44.000000
 +            gc:MLM.MATLAB_Coder=2.000000
 +            gc:MLM.MATLAB=204.000000
 +            gc:MLM.Database_Toolbox=1.000000
 +            gc:MLM.SIMULINK=100.000000
 +            gc:MLM.PDE_Toolbox=48.000000
 +            gc:MLM.GADS_Toolbox=1.000000
 +            gc:MLM.Symbolic_Toolbox=46.000000
 +            gc:MLM.Signal_Toolbox=146.000000
 +            gc:MLM.Financial_Toolbox=1.000000
 +            gc:MLM.Data_Acq_Toolbox=2.000000
 +            gc:MLM.Image_Acquisition_Toolbox=1.000000
 +            gc:MLM.Curve_Fitting_Toolbox=9.000000
 +            gc:MLM.Image_Toolbox=143.000000
 +            gc:MLM.Distrib_Computing_Toolbox=48.000000
 +            gc:MLM.OPC_Toolbox=1.000000
 +            gc:MLM.MPC_Toolbox=50.000000
 +            gc:MLM.Virtual_Reality_Toolbox=1.000000
 +            gc:MLM.Statistics_Toolbox=43.000000
 +            gc:MLM.Signal_Blocks=50.000000
 +            gc:MLM.Instr_Control_Toolbox=2.000000
 +            gc:MLM.MAP_Toolbox=12.000000
 +            gc:MLM.Communication_Toolbox=50.000000
 +            gc:MLM.Control_Toolbox=150.000000
 +            gc:MLM.Wavelet_Toolbox=1.000000
 +            gc:MLM.Bioinformatics_Toolbox=1.000000
 +     gc:MLM.Simulink_Control_Design=50.000000
 +     gc:MLM.Real-Time_Win_Target=1.000000
 +</code>
 +
 +Matlab jobs can be submitted to require a certain number of license seats to be available before a job will run. If there are inter-license dependencies for toolboxes, then you should specify all the licenses including Matlab and/or Simulink.
 +
 +For example, if a Matlab job requires the Financial toolbox, then you will also need to specify all the inter-related toolbox licenses required by the Financial toolbox such as the Statistics and Optimization toolboxes as well Matlab itself. See [[http://www.mathworks.com/products/availability|Mathworks System Requirements & Platform Availability by Product
 +]] for complete details.
 +
 +<code>
 + qsub -l MLM.MATLAB=1,MLM.Financial_Toolbox=1,MLM.Statistics_Toolbox=1,MLM.Optimization_Toolbox=1 ...
 +</code>
 +
 +Naturally, this isn't a to-the-moment mapping because the license server is not being queried constantly.  However, it's consumable, so it is keeping track of how many seats are unused every 6 minutes.
 +
 +This will be most helpful when submitting many Matlab jobs that require a toolbox with a low-seat count. They will wait for a toolbox seat to become available rather than trying to run and having many getting the "**License checkout failed**" message from MATLAB.
  
 ===== Matlab function ===== ===== Matlab function =====
Line 45: Line 116:
  
  
-The page will using a Matlab function to illustrate using Matlab in batch and interactively.  The function will be run on multiple cores using multiple computational threads, and 12 workers from a Matlab pool.  Finally it will be compiled an deployed.+The examples will be using a Matlab function to illustrate using Matlab in batch and interactively.  The function will be run on multiple cores using multiple computational threads, and 12 workers from a Matlab pool.  Finally it will be compiled and deployed.
  
-===== Batch example ===== 
  
-The basic steps to run [[:software:matlab#batch-job|batch MATLAB]]. 
 ==== Matlab script ==== ==== Matlab script ====
 First, write a Matlab script file. It should have a comment on the first line describing the purpose of the script and have the ''quit'' command on the last line. This script will call the [[#matlab-function|maxEig function]] 200 times and report the average: First, write a Matlab script file. It should have a comment on the first line describing the purpose of the script and have the ''quit'' command on the last line. This script will call the [[#matlab-function|maxEig function]] 200 times and report the average:
Line 68: Line 137:
 quit quit
 </file> </file>
 +
 +This is a detailed script example, which calls the maxEig function.  This example does no file I/O, all the I/O is to standard out.  In Matlab, assignments, not terminated by a semicolon, are display on the screen (standard out in batch).
 +
 +<note tip>
 +Several MATLAB commands could be added to the beginning of this script to set the maximum number of computational threads to the number of slots assigned to your job.  If the scheduler using CGROUPS to limit your job core count, then these commands are not necessary.
 +<code>
 +[compThreads,count]=sscanf(getenv('NSLOTS'),'%d');
 +if count == 1 
 +  warning('off','MATLAB:maxNumCompThreads:Deprecated');
 +  autoCompThreads = maxNumCompThreads(compThreads);
 +  disp(sprintf('NumCompThreads=%d, was %d',compThreads,autoCompThreads))
 +end
 +</code>
 +See [[maxNumCompThreadsGridEngine|Setting maximum number of computational threads]]</note>
 +
 +<note tip>
 +This script ends in a **__quit__** command (equivalent to MATLAB **__exit__**).  This is meant to be a complete script, which
 +terminates MATLAB when done.  If you run this from the bash command line with the ''-r script'' option, it will come back with a bash prompt when completed.  If this is run from a batch job, then you can do other commands in your batch script after the MATLAB script completes.
 +
 +Without the **__quit__** you will come back to the MATLAB prompt on completion for a interactive job.  If this is the last line of a batch queue script, then the only difference will be the MATLAB prompt ''>>'' at the very end of the output file.  MATLAB treats the end of batch script file the same as exiting the window, which is the preferred way to exit the MATLAB GUI.
 +</note>
  
 ==== Grid Engine script ==== ==== Grid Engine script ====
Line 135: Line 225:
 </code> </code>
  
-<note warning>See [[clusters/mills/matlab?&#matlab-licenses|Matlab licenses]] for details on specifying resources if there are limited number of license seats available for particular toolboxes.+<note warning>See [[#matlab-license-information|Matlab licenses]] for details on specifying resources if there are limited number of license seats available for particular toolboxes.
  
 In this example you will need a license for the base Matlab, and the parallel toolbox needs one license.  We are using the default local scheduler which give you 12 workers on the same node with one license. In this example you will need a license for the base Matlab, and the parallel toolbox needs one license.  We are using the default local scheduler which give you 12 workers on the same node with one license.
Line 292: Line 382:
 We have the correct Grid Engine options ''-pe threads 12'' for this case. We have the correct Grid Engine options ''-pe threads 12'' for this case.
  
-[[clusters:mills:matlab-two-samenode|Two Matlab interactive jobs on same node]]+[[software:matlab:mills:matlab-two-samenode|Two Matlab interactive jobs on same node]]
  
 ===== Batch parallel example ===== ===== Batch parallel example =====
Line 340: Line 430:
 ===== Interactive example ===== ===== Interactive example =====
  
-The basic steps to running a [[:software:matlab#interactive|MATLAB]] interactively on a compute node.  +This example is based on being in your workgroup environment, cd'ing to your MATLAB project directory and starting an interactive session on a compute node.
- +
-This demo starts in your MATLAB directory and with and active workgroup.  +
- +
 ==== Scheduling exclusive interactive job ==== ==== Scheduling exclusive interactive job ====
  
  • software/matlab/mills.1504817548.txt.gz
  • Last modified: 2017-09-07 16:52
  • by sraskar