{"id":1238,"date":"2023-05-19T08:54:43","date_gmt":"2023-05-19T12:54:43","guid":{"rendered":"https:\/\/blogs.mathworks.com\/matlab\/?p=1238"},"modified":"2023-05-19T10:05:27","modified_gmt":"2023-05-19T14:05:27","slug":"direct-submission-to-hpc-clusters-from-matlab","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/matlab\/2023\/05\/19\/direct-submission-to-hpc-clusters-from-matlab\/","title":{"rendered":"Direct submission to HPC clusters from MATLAB"},"content":{"rendered":"<div class=\"rtcContent\">\r\n<h4 style=\"margin: 10px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;\">More Compute, More Problems<\/h4>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">When it comes to High Performance Computing resources, I'm a lucky guy. I've got a fairly decent, 8 core desktop along with guest access to a reasonable number of academic HPC clusters around the world. Since I try to be a courteous guest, I make use of a healthy cloud budget when I need to do some heavy computations and use all of the major cloud providers.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In the old days, access to such a diverse array of compute was as much of a curse as it was a blessing. Many systems use different schedulers, for example. Even when two systems have the same scheduler (<a href=\"https:\/\/slurm.schedmd.com\/\">SLURM<\/a> usually), they have different module files, different authentication procedures and different file system layouts among other things. Making use of these computational riches can be a burden indeed.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Then you have a diverse array of access methods. From the classic ssh\/sftp command line interface to more modern things like <a href=\"https:\/\/openondemand.org\/\">OpenOn Demand<\/a>, <a href=\"https:\/\/www.cendio.com\/\">ThinLinc<\/a> or <a href=\"https:\/\/blogs.mathworks.com\/matlab\/2023\/01\/30\/official-mathworks-matlab-kernel-for-jupyter-released\/\">Jupyter notebooks<\/a>. It's all good stuff but it's a lot of messing around with an array of (admittedly fascinating) technologies when often all you want to do is get your results more quickly with as little fuss as possible.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Wouldn't it be nice if I could interact with all of these HPC and cloud machines without ever leaving MATLAB? No Linux, no schedulers and no shell scripting -- just MATLAB? Well you can, and I'll show you how.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><img decoding=\"async\" loading=\"lazy\" class=\"imageNode\" style=\"vertical-align: baseline; width: 370px; height: 181px;\" src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2023\/05\/directSubmitVer2_1.png\" alt=\"\" width=\"370\" height=\"181\" \/><\/div>\r\n<h4 style=\"margin: 10px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;\"><span style=\"font-weight: bold;\">Submit to all the things, direct from MATLAB<\/span><\/h4>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Imagine I have a function:<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-family: monospace;\">[result1,result2] = bigComputation(N)<\/span><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">It's a computation and it's big! The single input argument is an integer that defines just how big and it has two output arrays. Obviously it also runs in parallel because this is a HPC post.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">OK, so here's how I might run that function on my various machines using MATLAB. First, we define the problem and create objects representing my compute resources.<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 1px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Define how big a computation I want to do<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">N = 1e8;<\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Create parallel cluster objects representing my various computational resources<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">myMachine = parcluster(<span style=\"color: #a709f5;\">\"Processes\"<\/span>); <span style=\"color: #008013;\">% My local PC<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">onPremHPC = parcluster(<span style=\"color: #a709f5;\">\"University of Bantshire HPC\"<\/span>); <span style=\"color: #008013;\">% A SLURM based cluster<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 1px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">cloudHPC = parcluster(<span style=\"color: #a709f5;\">\"MyAWS Cluster\"<\/span>); <span style=\"color: #008013;\">% A MATLAB Cloud Center Cluster running on AWS<\/span><\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<ul style=\"margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px;\">\r\n \t<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">The <span style=\"font-family: monospace;\">Processes<\/span> profile is one of the MATLAB defaults and was there from when I installed. It <span style=\"font-weight: bold;\">points to my local machine<\/span> while the other two clusters involved some configuration.<\/li>\r\n \t<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">The <span style=\"font-family: monospace;\">onPremHPC<\/span> cluster profile was given to me by the system administrator of the <span style=\"font-weight: bold;\">SLURM-based cluster<\/span> who had configured their machine using the <a href=\"https:\/\/github.com\/mathworks\/matlab-parallel-slurm-plugin\">MATLAB SLURM plugin on GitHub<\/a> along with a little help from our HPC Support team.<\/li>\r\n \t<li style=\"margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap;\">I was able to import the <span style=\"font-family: monospace;\">cloudHPC<\/span> profile after configuring an<span style=\"font-weight: bold;\"> AWS cloud cluster<\/span> using<a href=\"https:\/\/cloudcenter.mathworks.com\/resource\/\"> MathWorks Cloud Center<\/a>.<\/li>\r\n<\/ul>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The profile configuration only had to be done once. One day I'll tell you how it's done but I did it so long ago I've forgotten the steps, and I need this post published in time for <a href=\"https:\/\/www.isc-hpc.com\/\">International Supercomputing 2023 (ISC23)<\/a>, so today I'm just showing you the day-to-day workflow.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">All that remains is to submit the function using the MATLAB <a href=\"https:\/\/www.mathworks.com\/help\/parallel-computing\/batch.html\"><span style=\"font-family: monospace;\">batch<\/span><\/a> command. The structure of which is<\/div>\r\n<div class=\"preformatted-matlab\" style=\"margin: 10px 3px 10px 55px; padding: 10px 10px 10px 5px;\">\r\n<div style=\"border-radius: 0px; padding: 0px; line-height: 15.6px; min-height: 16px; white-space: pre; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 12px; border: 0px none #212121;\"><span style=\"white-space: pre;\">batch(clusterObject, @functionToRun, numberOfOutputArguments,{inputArguments},options) <\/span><\/div>\r\n<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The only option I'm going to use today is <span style=\"font-family: monospace;\">Pool<\/span> which requests a specific number of workers on either my local machine or the remote resource.<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 1px solid #d9d9d9; border-bottom: 0px none #212121; border-radius: 4px 4px 0px 0px; padding: 6px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">% Submit to local machine<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">LocalJob = batch(myMachine,@bigComputation,2,{N},Pool=4); <span style=\"color: #008013;\">% Submit to a pool of 4 workers on my local machine<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 0px none #212121; border-radius: 0px; padding: 0px 45px 0px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\"><span style=\"color: #008013;\">%Submit to SLURM cluster<\/span><\/span><\/div>\r\n<\/div>\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-left: 1px solid #d9d9d9; border-right: 1px solid #d9d9d9; border-top: 0px none #212121; border-bottom: 1px solid #d9d9d9; border-radius: 0px 0px 4px 4px; padding: 0px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px;\"><span style=\"white-space: pre;\">onPremJob = batch(onPremHPC,@bigComputation,2,{N},Pool=31); <span style=\"color: #008013;\">% Submit to a pool of 31 workers on a SLURM HPC cluster<\/span><\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Since I'm running the same computation on both machines, these two calls to <span style=\"font-family: monospace;\">batch<\/span> are almost identical but what's happening behind the scenes is very different!<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-weight: bold;\">The submission to my local machine<\/span> is just going to run it on a local <span style=\"font-family: monospace;\">parpool<\/span> almost exactly as if I had run the function directly in the command line. The main benefit of running parallel jobs locally this way is that it is non-blocking. While 4 cores service the job in the background, I can use my remaining cores to work with MATLAB interactively.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-weight: bold;\">The submission to the SLURM cluster<\/span> is a very different beast. Behind the scenes, it first logs into the HPC cluster; giving me any authentication challenge you might expect. Two Factor Authentication is not a problem. Then, it compresses my code, transfers it to the cluster via sftp, creates and submits a SLURM job to the system....all according to the policies laid out by the system administrator. I didn't need to worry about any of this, I just used the line above.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><span style=\"font-weight: bold;\">The submission to the AWS cluster has an extra step<\/span>. I pay for it by the minute so I keep it switched off to save money. As such, I have to start it first!<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">start(cloudHPC)<\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">This kicks off the start-up sequence of the cloud cluster and returns almost immediately, allowing you to continue interactive use on your local machine. If you want to ensure that <span style=\"font-family: monospace;\">cloudHPC <\/span>has completed its set up before running the next line of code, you'll need to do<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">wait(cloudHPC) <span style=\"color: #008013;\">% wait until cloudHPC is ready to accept jobs<\/span><\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Other than that, the structure of the batch command is identical again.<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">cloudJob = batch(cloudHPC,@bigComputation,2,{N},Pool=63); <span style=\"color: #008013;\">% Submit to 63 workers on the cloud cluster<\/span><\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">In the configuration of <span style=\"font-family: monospace;\">cloudHPC <\/span>(Not discussed here), I've set it up to auto-shutdown once the cluster is idle. As such, I don't need to worry about running up a huge cloud bill by accident.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">If I wanted to be sure though, I could first wait for the job to finish<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">wait(cloudJob)<\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">and then shutdown the cluster explicitly<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper\">\r\n<div style=\"border-radius: 4px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">shutdown(cloudHPC)<\/span><\/div>\r\n<\/div>\r\n<\/div>\r\n<h4 style=\"margin: 3px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;\">Getting the results<\/h4>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">The jobs are running on my machines and I could have monitored their state if I liked using the <a href=\"https:\/\/www.mathworks.com\/help\/parallel-computing\/job-monitor.html\">Job Monitor<\/a>. Instead, I just went for a walk in the sunshine and now its time to get my results. I can fetch the outputs of any job with the <span style=\"font-family: monospace;\">fetchOutputs<\/span> command. Here's the result from the run on my local machine.<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper outputs\">\r\n<div style=\"border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">fetchOutputs(LocalJob)<\/span><\/div>\r\n<div style=\"color: #212121; padding: 10px 0px 6px 17px; background: #ffffff none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;\">\r\n<div class=\"inlineElement eoOutputWrapper embeddedOutputsVariableTableElement\" style=\"width: calc(100% - 5px);\" data-testid=\"output_0\">\r\n<div id=\"variableeditor_client_Document_0\" class=\"ClientDocument veSpecifier table\" tabindex=\"0\">\r\n<div class=\"summaryBar\" style=\"font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;\">ans = <span style=\"color: #b3b3b3; font-style: normal;\">1\u00d72 cell <\/span><\/div>\r\n<div id=\"variableeditor_TableViewModel_0\" class=\"cell ClientViewDiv hasSummaryBar\" style=\"width: 100%; overflow: auto;\" data-viewid=\"__1\">\r\n<table style=\"border-spacing: 0px; border-collapse: collapse;\" cellspacing=\"0\">\r\n<thead>\r\n<tr>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid #bfbfbf; text-align: left; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\"><\/th>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid #bfbfbf; text-align: center; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">1<\/th>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid #bfbfbf; text-align: center; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">2<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">1<\/th>\r\n<td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left;\">0.1349<\/td>\r\n<td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left;\">0.6744<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<\/div>\r\n<div class=\"outputLayer selectedOutputDecorationLayer doNotExport\"><\/div>\r\n<div class=\"outputLayer activeOutputDecorationLayer doNotExport\"><\/div>\r\n<div class=\"outputLayer scrollableOutputDecorationLayer doNotExport\"><\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Recall that my function <span style=\"font-family: monospace;\">bigCompute(N)<\/span> had 2 outputs and here they are! Hardly seems worth it for several hours of compute but that's often the way of big HPC jobs. Let's hope that those numbers really mean something scientifically!<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Fetching the outputs from the SLURM and Cloud machines is just as easy. Here's the result from the SLURM cluster<\/div>\r\n<div style=\"background-color: #f5f5f5; margin: 10px 0 10px 0;\">\r\n<div class=\"inlineWrapper outputs\">\r\n<div style=\"border-radius: 4px 4px 0px 0px; padding: 6px 45px 4px 13px; line-height: 18.004px; min-height: 0px; white-space: nowrap; color: #212121; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; border: 1px solid #d9d9d9;\"><span style=\"white-space: pre;\">fetchOutputs(onPremJob)<\/span><\/div>\r\n<div style=\"color: #212121; padding: 10px 0px 6px 17px; background: #ffffff none repeat scroll 0% 0% \/ auto padding-box border-box; font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; font-size: 14px; overflow-x: hidden; line-height: 17.234px;\">\r\n<div class=\"inlineElement eoOutputWrapper embeddedOutputsVariableTableElement\" style=\"width: calc(100% - 5px);\" data-testid=\"output_1\">\r\n<div id=\"variableeditor_client_Document_1\" class=\"ClientDocument veSpecifier table\" tabindex=\"0\">\r\n<div class=\"summaryBar\" style=\"font-size: 12px; font-family: Consolas, Inconsolata, Menlo, monospace;\">ans = <span style=\"color: #b3b3b3; font-style: normal;\">1\u00d72 cell <\/span><\/div>\r\n<div id=\"variableeditor_TableViewModel_1\" class=\"cell ClientViewDiv hasSummaryBar\" style=\"width: 100%; overflow: auto;\" data-viewid=\"__1\">\r\n<table style=\"border-spacing: 0px; border-collapse: collapse;\" cellspacing=\"0\">\r\n<thead>\r\n<tr>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border: 1px solid #bfbfbf; text-align: left; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\"><\/th>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid #bfbfbf; text-align: center; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">1<\/th>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 82px; min-width: 82px; max-width: 82px; border: 1px solid #bfbfbf; text-align: center; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">2<\/th>\r\n<\/tr>\r\n<\/thead>\r\n<tbody>\r\n<tr>\r\n<th style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 6px 3px 3px; width: 34px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left; background-color: #f5f5f5; color: rgba(0, 0, 0, 0.75); font-weight: bold; box-sizing: border-box;\">1<\/th>\r\n<td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left;\">0.1349<\/td>\r\n<td style=\"text-overflow: ellipsis; font-family: Arial, sans-serif; font-size: 12px; overflow: hidden; padding: 3px; width: 82px; min-width: 82px; max-width: 82px; border-width: 0px 1px 1px; border-style: solid; border-color: #bfbfbf; border-image: initial; text-align: left;\">0.6744<\/td>\r\n<\/tr>\r\n<\/tbody>\r\n<\/table>\r\n<\/div>\r\n<\/div>\r\n<div class=\"outputLayer selectedOutputDecorationLayer doNotExport\"><\/div>\r\n<div class=\"outputLayer activeOutputDecorationLayer doNotExport\"><\/div>\r\n<div class=\"outputLayer scrollableOutputDecorationLayer doNotExport\"><\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<div style=\"margin: 10px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">Same calculation, same result! No surprise there but think about what was actually done here? MATLAB connected to the cluster, fetched the results and returned them to this Live Script with just a single command. No ssh, no sftp, just MATLAB<\/div>\r\n<h4 style=\"margin: 10px 10px 5px 4px; padding: 0px; line-height: 18px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 15px; font-weight: bold; text-align: left;\">Want this on your HPC Cluster?<\/h4>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">I have omitted so many details it's almost criminal! There is so much more that can be done that we could (and do!) make entire, day-long tutorials on this stuff. The aim of this post is to introduce the skeleton of this workflow, showing how easy HPC in MATLAB can be, and hopefully start some conversations with MATLAB users and HPC sysadmins around the world. If you want to learn more, message me on <a href=\"https:\/\/twitter.com\/walkingrandomly\">Twitter<\/a>, <a href=\"https:\/\/www.linkedin.com\/in\/mike-croucher-32336113\/\">LinkedIn<\/a> or head over to <a href=\"https:\/\/www.mathworks.com\/products\/matlab-parallel-server.html\">MATLAB Parallel Server - MATLAB (mathworks.com)<\/a> and click the link at the bottom right.<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\">I'll also be at International Super Computing 2023 in Hamburg next week wearing a MATLAB cap for anyone who wants to talk in person<\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<div style=\"margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: #212121; font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left;\"><\/div>\r\n<\/div>\r\n<script type=\"text\/javascript\">var css = '.embeddedOutputsVariableTableElement .ClientViewDiv  table tr {  height: 22px;  white-space: nowrap;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr td,.embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {  background-color:white;  text-overflow: ellipsis;  font-family: Arial, sans-serif;  font-size: 12px;  overflow : hidden;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr span {  text-overflow: ellipsis;  padding: 3px;} .embeddedOutputsVariableTableElement .ClientViewDiv  table tr th {    color: rgba(0,0,0,0.5);  padding: 3px;  font-size: 9px;}'; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2023\/05\/directSubmitVer2_1.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>\r\nMore Compute, More Problems\r\nWhen it comes to High Performance Computing resources, I'm a lucky guy. I've got a fairly decent, 8 core desktop along with guest access to a reasonable number of... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/matlab\/2023\/05\/19\/direct-submission-to-hpc-clusters-from-matlab\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":1232,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[42,14],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1238"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/comments?post=1238"}],"version-history":[{"count":4,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1238\/revisions"}],"predecessor-version":[{"id":1256,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1238\/revisions\/1256"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media\/1232"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media?parent=1238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/categories?post=1238"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/tags?post=1238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}