Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
software:matlab:matlab [2019-08-27 15:43] – [Create a queue script file] anita | software:matlab:matlab [2021-02-24 16:37] (current) – [Details by cluster] anita | ||
---|---|---|---|
Line 8: | Line 8: | ||
====== License information ====== | ====== License information ====== | ||
- | MATLAB is product licensed by Mathworks. | + | MATLAB is product licensed by Mathworks. |
The Mathworks R2013b and newer license server is being queried every 6 minutes on each cluster for available seats licensed for Matlab, Simulink and associated toolboxes. | The Mathworks R2013b and newer license server is being queried every 6 minutes on each cluster for available seats licensed for Matlab, Simulink and associated toolboxes. | ||
Line 32: | Line 32: | ||
When you have a MATLAB job tested and debugged in a project directory, you are ready run on a cluster. | When you have a MATLAB job tested and debugged in a project directory, you are ready run on a cluster. | ||
- | ===== Copy the project folder ===== | + | See [[# |
- | + | ||
- | Copy the project folder to a directory on the cluster. | + | |
- | Use any [[: | + | |
- | + | ||
- | ====== Batch job====== | + | |
- | + | ||
- | See [[#cluster | + | |
- | + | ||
- | <note important> | + | |
- | + | ||
- | MATLAB has a new version twice a year. It is important to keep the version you use on your desktop the same as the | + | |
- | one on the cluster. | + | |
- | < | + | |
- | vpkg_versions matlab | + | |
- | </ | + | |
- | will show you the versions available on a cluster. | + | |
- | </ | + | |
- | + | ||
- | <note tip> | + | |
- | + | ||
- | It is frequently advisable to keep your MATLAB project clean from non-MATLAB files such as the queue | + | |
- | script file and the script output file. But you may combine them, and even use the MATLAB editor to | + | |
- | create the script file and look at the output file. | + | |
- | If you create the file on a PC, take care to not transfer the files as binary. See Transfer Files for the appropriate cluster. | + | |
- | + | ||
- | When you have one combined directory, do not put the '' | + | |
- | to the project directory using '' | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ===== Create a job script file ===== | + | |
- | You should create a job script file to submit a batch job. Start by modifying a job template file (''/ | + | |
- | In your copy change the commented '' | + | |
- | require MATLAB, and then add your shell commands to the end of the file. Your copy may contain the lines: | + | |
- | < | + | |
- | # Add vpkg_require commands after this line: | + | |
- | vpkg_require matlab | + | |
- | + | ||
- | # Now append all of your shell commands necessary to run your program | + | |
- | # after this line: | + | |
- | cd project_directory | + | |
- | matlab | + | |
- | </ | + | |
- | The '' | + | |
- | one line **'' | + | |
- | + | ||
- | For more examples, including examples that use multiple computational threads or the Parallel toolbox, see the [[#cluster details]] | + | |
- | ===== Submit batch job ===== | + | |
- | Your shell must be in a [[general: | + | |
- | to submit any jobs. | + | |
- | Use the '' | + | |
- | and note the ''<< | + | |
- | submit the job with: | + | |
- | < | + | |
- | qsub matlab_first.qs | + | |
- | </ | + | |
- | + | ||
- | <note important> | + | |
- | + | ||
- | This is the message you get if you are not in workgroup. | + | |
- | </ | + | |
- | + | ||
- | <note warning> | + | |
- | + | ||
- | It is true that a queue script file is (usually) a bash script, but it must be executed with the '' | + | |
- | </ | + | |
- | + | ||
- | ===== Wait for job to complete ===== | + | |
- | You can [[general: | + | |
- | For example, to list the information for job ''<< | + | |
- | < | + | |
- | qstat -j << | + | |
- | </ | + | |
- | + | ||
- | For long running | + | |
- | complete. | + | |
- | ===== Post process job ===== | + | |
- | All MATLAB output data files will be in the project directory, but the MATLAB standard output will be in | + | |
- | the current directory, from which you submitted the job. Look for a file ending in your assigned JOBID. | + | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | ====== Interactive job ====== | + | |
- | + | ||
- | Here are specific details for running MATLAB as an [[general: | + | |
- | + | ||
- | ===== Command-line ===== | + | |
- | + | ||
- | You should work on a compute node when in command-line MATLAB. | + | |
- | Your shell must be in a [[general: | + | |
- | to submit a single threaded interactive job using '' | + | |
- | + | ||
- | < | + | |
- | qlogin | + | |
- | vpkg_require matlab | + | |
- | cd project_directory | + | |
- | matlab -nodesktop -singleCompThread | + | |
- | </ | + | |
- | + | ||
- | This will start a interactive command-line session in your terminal window. | + | |
- | + | ||
- | ===== Desktop ===== | + | |
- | + | ||
- | You should be on a compute node before you start MATLAB. | + | |
- | To start a MATLAB desktop (GUI mode) on a cluster, you must be running an X11 server and you must have | + | |
- | [[general: | + | |
- | X11 tunneling]]. | + | |
- | + | ||
- | Your shell must be in a [[general: | + | |
- | to submit a job using '' | + | |
- | + | ||
- | < | + | |
- | qlogin -l exclusive=1 | + | |
- | vpkg_require matlab | + | |
- | cd project_directory | + | |
- | matlab | + | |
- | </ | + | |
- | + | ||
- | This will start a interactive DESKTOP session on you X11 screen. | + | |
- | + | ||
- | + | ||
- | See [[: | + | |
- | + | ||
- | ====== Compiling with MATLAB ====== | + | |
- | + | ||
- | We show the three most common ways to work with compilers when using MATLAB. | + | |
- | + | ||
- | - Compiling your matlab code to run in the MCR (Matlab Compiler Runtime) | + | |
- | - Compiling your C or Fortran program to call MATLAB engine. | + | |
- | - Compiling your own function in C or Fortran to be used in a MATLAB session. | + | |
- | + | ||
- | < | + | |
- | < | + | |
- | Warning: You are using gcc version ' | + | |
- | with MEX is ' | + | |
- | http:// | + | |
- | </ | + | |
- | But the compilation completes successfully. | + | |
- | </ | + | |
- | + | ||
- | ===== Compiling your MATLAB ===== | + | |
- | + | ||
- | There is an example MCR project in the ''/ | + | |
- | + | ||
- | ==== Copy dev-projects template ==== | + | |
- | + | ||
- | On the head node | + | |
- | < | + | |
- | cp -r / | + | |
- | cd MCR | + | |
- | </ | + | |
- | + | ||
- | ==== Compile with make ==== | + | |
- | + | ||
- | Now compile on the compute node by using | + | |
- | + | ||
- | < | + | |
- | qlogin | + | |
- | make | + | |
- | </ | + | |
- | + | ||
- | < | + | |
- | </ | + | |
- | + | ||
- | Resulting output from the make command: | + | |
- | < | + | |
- | Adding package `mcr/ | + | |
- | make[1]: Entering directory `/ | + | |
- | mcc -o maxEig -R " | + | |
- | Compiler version: 5.2 (R2014b) | + | |
- | Dependency analysis by REQUIREMENTS. | + | |
- | Parsing file "/ | + | |
- | (Referenced from: " | + | |
- | Deleting 0 temporary MEX authorization files. | + | |
- | Generating file "/ | + | |
- | Generating file " | + | |
- | make[1]: Leaving directory `/ | + | |
- | </ | + | |
- | Take note of the package added, and the files that are generated. | + | |
- | You must add the package in your batch script or to test interactively. | + | |
- | + | ||
- | ==== test interactively ==== | + | |
- | + | ||
- | To test interactively on the same compute node. | + | |
- | < | + | |
- | vpkg_require mcr/ | + | |
- | time ./maxEig 20.8 | + | |
- | </ | + | |
- | <note tip>This example is designed as a test for batch computing, and takes about 15 minutes to complete. If you | + | |
- | change the MATLAB statement dim=10000 to dim=1000, and recompile, it will take about 10 seconds</ | + | |
- | + | ||
- | ==== back to the head node ==== | + | |
- | When done, exit the compute node. | + | |
- | < | + | |
- | exit | + | |
- | </ | + | |
- | + | ||
- | ==== Copy array job example ==== | + | |
- | + | ||
- | < | + | |
- | cp / | + | |
- | vi matlab-mcr.qs | + | |
- | diff / | + | |
- | </ | + | |
- | The '' | + | |
- | < | + | |
- | 46c46 | + | |
- | < # -l m_mem_free=5G | + | |
- | --- | + | |
- | > #$ -l m_mem_free=3G | + | |
- | 51c51 | + | |
- | < # -t 1-4 | + | |
- | --- | + | |
- | > #$ -t 1-100 | + | |
- | 63c63,64 | + | |
- | < vpkg_require mcr/ | + | |
- | --- | + | |
- | > vpkg_require mcr/ | + | |
- | > let lambda=" | + | |
- | 79c80 | + | |
- | < MCR_EXECUTABLE_FLAGS=(" | + | |
- | --- | + | |
- | > MCR_EXECUTABLE_FLAGS=(" | + | |
- | </ | + | |
- | To submit a standby array job that has 100 tasks. | + | |
- | < | + | |
- | qsub -l standby=1 matlab-mcr.qs | + | |
- | </ | + | |
- | + | ||
- | Example | + | |
- | < | + | |
- | [(it_css: | + | |
- | Your job-array 627074.1-100: | + | |
- | [(it_css: | + | |
- | Mon Apr 11 14:56:26 EDT 2016 | + | |
- | [(it_css: | + | |
- | Mon Apr 11 15:17:33 EDT 2016 | + | |
- | [(it_css: | + | |
- | 100 | + | |
- | </ | + | |
- | There are 100 output files with the names matlab-mcr.qs.o627074.1 to matlab-mcr.qs.o627074.100 | + | |
- | For example file 50: | + | |
- | < | + | |
- | [CGROUPS] UD Grid Engine cgroup setup commencing | + | |
- | [CGROUPS] Setting 3221225472 bytes (vmem none bytes) on n106 (master) | + | |
- | [CGROUPS] | + | |
- | [CGROUPS] done. | + | |
- | + | ||
- | Adding package `mcr/ | + | |
- | GridEngine parameters: | + | |
- | MCR_ROOT = / | + | |
- | MCR executable = / | + | |
- | flags = 49 | + | |
- | MCR_CACHE_ROOT = / | + | |
- | -- begin maxEig run -- | + | |
- | + | ||
- | maxe = | + | |
- | + | ||
- | | + | |
- | + | ||
- | -- end maxEig run -- | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | [[more examples]] | + | |
- | + | ||
- | + | ||
- | ===== Compiling your code to use MATLAB engine ====== | + | |
- | + | ||
- | There is an simple example function '' | + | |
- | + | ||
- | On the head node and in a workgroup shell: | + | |
- | + | ||
- | < | + | |
- | vpkg_require matlab/ | + | |
- | cp $MATLABROOT/ | + | |
- | export LD_LIBRARY_PATH=$MATLABROOT/ | + | |
- | mex -client engine fengdemo.F | + | |
- | </ | + | |
- | + | ||
- | To start MATLAB on a compute node to test this new program: | + | |
- | + | ||
- | < | + | |
- | qlogin | + | |
- | vpkg_require matlab/ | + | |
- | export LD_LIBRARY_PATH=$MATLABROOT/ | + | |
- | ./ | + | |
- | exit | + | |
- | </ | + | |
- | + | ||
- | Step one of the fengdemo should give the plot: | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | Step two should give the table: | + | |
- | + | ||
- | < | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | </ | + | |
- | + | ||
- | ===== Compiling your own MATLAB function ====== | + | |
- | + | ||
- | There is an simple example function '' | + | |
- | + | ||
- | On the head node and in a workgroup shell: | + | |
- | + | ||
- | < | + | |
- | vpkg_require matlab/ | + | |
- | cp $MATLABROOT/ | + | |
- | mex timestwo.c | + | |
- | </ | + | |
- | + | ||
- | To start MATLAB on a compute node to test this new function: | + | |
- | + | ||
- | < | + | |
- | qlogin | + | |
- | vpkg_require matlab/ | + | |
- | matlab -nodesktop | + | |
- | timestwo(4) | + | |
- | quit | + | |
- | exit | + | |
- | </ | + | |
- | + | ||
- | You should get the answer | + | |
- | + | ||
- | < | + | |
- | >> timestwo(4) | + | |
- | + | ||
- | ans = | + | |
- | + | ||
- | 8 | + | |
- | + | ||
- | >> | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | + | ||
====== Parallel job ====== | ====== Parallel job ====== | ||
Line 404: | Line 53: | ||
- | =====Details by clusters===== | + | ======Details by cluster====== |
+ | * [[software: | ||
* [[software: | * [[software: | ||
* [[software: | * [[software: |