{"id":3959,"date":"2021-03-08T09:22:15","date_gmt":"2021-03-08T07:22:15","guid":{"rendered":"http:\/\/ucthpc.uct.ac.za\/?page_id=3959"},"modified":"2021-04-09T16:40:23","modified_gmt":"2021-04-09T14:40:23","slug":"matlab-standard-job-submission","status":"publish","type":"page","link":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/","title":{"rendered":"MATLAB standard job submission"},"content":{"rendered":"<p><strong>Getting Started with Parallel Computing using MATLAB on the HPC Cluster<\/strong><\/p>\n<p><strong>Note:<\/strong> If you are not making use of parallel functions then you can ignore this document and just launch standard MATLAB jobs with the following in your shell script:<\/p>\n<pre>module load software\/matlab-R2020b\r\nmatlab -batch my_matlab_script<\/pre>\n<p>&nbsp;<\/p>\n<p>This document provides the steps to configure MATLAB to submit jobs to a cluster, retrieve results, and debug errors.<\/p>\n<p><strong>CONFIGURATION<\/strong><\/p>\n<p>After logging into the cluster use the module command to select the version of MATLAB you require:<\/p>\n<pre>module load software\/matlab-R2019b\r\nor\u00a0\r\nmodule load software\/matlab-R2020b<\/pre>\n<p>Then configure MATLAB to run parallel jobs on your cluster by calling the shell script configCluster.sh\u00a0\u00a0 This only needs to be called once per version of MATLAB.<\/p>\n<pre>$ module load software\/matlab-R2019b\r\n$ configCluster.sh<\/pre>\n<p>Jobs will now default to the cluster rather than submit to the local machine.<\/p>\n<p><strong>CONFIGURING JOBS<\/strong><\/p>\n<p>Prior to submitting the job, we can specify various parameters to pass to our jobs, such as queue, e-mail, walltime, etc.\u00a0 <em>Only WallTime is required.<\/em><\/p>\n<pre>&gt;&gt; <span style=\"color: #008000;\">% Get a handle to the cluster<\/span>\r\n&gt;&gt; c = parcluster;\r\n\r\n<span style=\"color: #008000;\">[<strong>REQUIRED<\/strong>]<\/span>\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Specify the walltime (e.g. 5 hours)<\/span>\r\n&gt;&gt; c.AdditionalProperties.WallTime = '05:00:00';\r\n\r\n<span style=\"color: #008000;\">[<strong>OPTIONAL<\/strong>]<\/span>\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Specify an account to use for MATLAB jobs<\/span>\r\n&gt;&gt; c.AdditionalProperties.AccountName = 'account-name';\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Specify e-mail address to receive notifications about your job<\/span>\r\n&gt;&gt; c.AdditionalProperties.EmailAddress = 'user-id@uct.ac.za';\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Request 2 Fermi GPU cards per node<\/span>\r\n&gt;&gt; c.AdditionalProperties.GpuCard = 'fermi';\r\n&gt;&gt; c.AdditionalProperties.GpusPerNode = 2;\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Specify memory to use for MATLAB jobs, per core (MB)<\/span>\r\n&gt;&gt; c.AdditionalProperties.MemUsage = '4000';\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Specify a queue to use for MATLAB jobs\u00a0<\/span>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\r\n&gt;&gt; c.AdditionalProperties.QueueName = 'queue-name';<\/pre>\n<p>Save changes after modifying AdditionalProperties for the above changes to persist between MATLAB sessions.<\/p>\n<pre>&gt;&gt; c.saveProfile<\/pre>\n<p>To see the values of the current configuration options, display AdditionalProperties.<\/p>\n<pre>&gt;&gt; % To view current properties\r\n&gt;&gt; c.AdditionalProperties<\/pre>\n<p>Unset a value when no longer needed.<\/p>\n<pre>&gt;&gt; <span style=\"color: #008000;\">% Turn off email notifications<\/span>\r\n&gt;&gt; c.AdditionalProperties.EmailAddress = '';\r\n&gt;&gt; c.saveProfile<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>INTERACTIVE JOBS<\/strong><\/p>\n<p>To run an interactive pool job on the cluster, continue to use parpool as you\u2019ve done before.<\/p>\n<pre>&gt;&gt; <span style=\"color: #008000;\">% Get a handle to the cluster<\/span>\r\n&gt;&gt; c = parcluster;\r\n\r\n&gt;&gt; <span style=\"color: #008000;\">% Open a pool of 4 workers on the cluster<\/span>\r\n&gt;&gt; p = c.parpool(4);<\/pre>\n<p>Rather than running local on the local machine, the pool can now run across multiple nodes on the cluster.<\/p>\n<pre>&gt;&gt; <span style=\"color: #008000;\">% Run a parfor over 1000 iterations<\/span>\r\n&gt;&gt; parfor idx = 1:1000\r\n      a(idx) = \u2026\r\n   end<\/pre>\n<p>Once we\u2019re done with the pool, delete it.<\/p>\n<pre>&gt;&gt; <span style=\"color: #008000;\">% Delete the pool<\/span>\r\n&gt;&gt; p.delete<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>EXAMPLES<\/strong><\/p>\n<p>Running a job on multiple cores on a single cluster node:<\/p>\n<pre>c = parcluster;\r\nc.AdditionalProperties.ProcsPerNode = 4\r\nc.saveProfile\r\np = c.parpool(4);\r\nspmd, A = rand(1000); b = rand(1000,1); x = A\\b; end<\/pre>\n<p>&nbsp;<\/p>\n<p>Running a job across multiple nodes:<\/p>\n<pre>c = parcluster;\r\nc.AdditionalProperties.ProcsPerNode = 1\r\nc.saveProfile\r\np = c.parpool(4);\r\nspmd, A = distributed.rand(10000); b = distributed.rand(10000,1); x = A\\b; end<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>TO LEARN MORE<\/strong><\/p>\n<p>To learn more about the MATLAB Parallel Computing Toolbox, check out these resources:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.mathworks.com\/products\/parallel-computing\/code-examples.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Coding Examples<\/a><\/li>\n<li><a href=\"http:\/\/www.mathworks.com\/help\/distcomp\/index.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Documentation<\/a><\/li>\n<li><a href=\"http:\/\/www.mathworks.com\/products\/parallel-computing\/index.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Overview<\/a><\/li>\n<li><a href=\"http:\/\/www.mathworks.com\/products\/parallel-computing\/tutorials.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Tutorials<\/a><\/li>\n<li><a href=\"http:\/\/www.mathworks.com\/products\/parallel-computing\/videos.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Videos<\/a><\/li>\n<li><a href=\"http:\/\/www.mathworks.com\/products\/parallel-computing\/webinars.html\" target=\"_blank\" rel=\"noopener\">Parallel Computing Webinars<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Getting Started with Parallel Computing using MATLAB on the HPC Cluster Note: If you are not making use of parallel functions then you can ignore this document and just launch standard MATLAB jobs with the following in your shell script: module load software\/matlab-R2020b matlab -batch my_matlab_script &nbsp; This document provides the steps to configure MATLAB&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MATLAB standard job submission - UCT HPC<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MATLAB standard job submission - UCT HPC\" \/>\n<meta property=\"og:description\" content=\"Getting Started with Parallel Computing using MATLAB on the HPC Cluster Note: If you are not making use of parallel functions then you can ignore this document and just launch standard MATLAB jobs with the following in your shell script: module load software\/matlab-R2020b matlab -batch my_matlab_script &nbsp; This document provides the steps to configure MATLAB...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/\" \/>\n<meta property=\"og:site_name\" content=\"UCT HPC\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-09T14:40:23+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/\",\"name\":\"MATLAB standard job submission - UCT HPC\",\"isPartOf\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#website\"},\"datePublished\":\"2021-03-08T07:22:15+00:00\",\"dateModified\":\"2021-04-09T14:40:23+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/#breadcrumb\"},\"inLanguage\":\"en-ZA\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/ucthpc.uct.ac.za\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"MATLAB standard job submission\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#website\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/\",\"name\":\"UCT HPC\",\"description\":\"University of Cape Town High Performance Computing\",\"publisher\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/ucthpc.uct.ac.za\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-ZA\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#organization\",\"name\":\"University of Cape Town High Performance Computing\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-ZA\",\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png\",\"contentUrl\":\"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png\",\"width\":450,\"height\":423,\"caption\":\"University of Cape Town High Performance Computing\"},\"image\":{\"@id\":\"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MATLAB standard job submission - UCT HPC","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/","og_locale":"en_US","og_type":"article","og_title":"MATLAB standard job submission - UCT HPC","og_description":"Getting Started with Parallel Computing using MATLAB on the HPC Cluster Note: If you are not making use of parallel functions then you can ignore this document and just launch standard MATLAB jobs with the following in your shell script: module load software\/matlab-R2020b matlab -batch my_matlab_script &nbsp; This document provides the steps to configure MATLAB...","og_url":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/","og_site_name":"UCT HPC","article_modified_time":"2021-04-09T14:40:23+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/","url":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/","name":"MATLAB standard job submission - UCT HPC","isPartOf":{"@id":"https:\/\/ucthpc.uct.ac.za\/#website"},"datePublished":"2021-03-08T07:22:15+00:00","dateModified":"2021-04-09T14:40:23+00:00","breadcrumb":{"@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/#breadcrumb"},"inLanguage":"en-ZA","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/ucthpc.uct.ac.za\/index.php\/matlab-standard-job-submission\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ucthpc.uct.ac.za\/"},{"@type":"ListItem","position":2,"name":"MATLAB standard job submission"}]},{"@type":"WebSite","@id":"https:\/\/ucthpc.uct.ac.za\/#website","url":"https:\/\/ucthpc.uct.ac.za\/","name":"UCT HPC","description":"University of Cape Town High Performance Computing","publisher":{"@id":"https:\/\/ucthpc.uct.ac.za\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ucthpc.uct.ac.za\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-ZA"},{"@type":"Organization","@id":"https:\/\/ucthpc.uct.ac.za\/#organization","name":"University of Cape Town High Performance Computing","url":"https:\/\/ucthpc.uct.ac.za\/","logo":{"@type":"ImageObject","inLanguage":"en-ZA","@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/","url":"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png","contentUrl":"https:\/\/ucthpc.uct.ac.za\/wp-content\/uploads\/2015\/09\/logocircless.png","width":450,"height":423,"caption":"University of Cape Town High Performance Computing"},"image":{"@id":"https:\/\/ucthpc.uct.ac.za\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/pages\/3959"}],"collection":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/comments?post=3959"}],"version-history":[{"count":13,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/pages\/3959\/revisions"}],"predecessor-version":[{"id":4000,"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/pages\/3959\/revisions\/4000"}],"wp:attachment":[{"href":"https:\/\/ucthpc.uct.ac.za\/index.php\/wp-json\/wp\/v2\/media?parent=3959"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}