Difference between revisions of "Training/Matlab-Viper-plugin"

From HPC
Jump to: navigation , search
(Batch job)
m
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Matlab viper plugin=
+
<!--
please note this page is still under development.  
+
__TOC__
 +
 
 +
=Matlab Viper plugin=
 +
 
 +
Please note this page is in pre-release status and may be changed at any time.
 +
 
 
==Introduction==
 
==Introduction==
There is a feature in Matlab that enables you to submit jobs to clusters directly from your Matlab client (normal desktop Matlab). we were able to develop Matlab-Viper plugin that utilise this feature and integrate Matlab with viper to enable all our Matlab users to submit some Matlab jobs to viper easily without the need to know much about HPC or Linux. Everything could be done from the normal desktop Matlab version that many users are already using.  
+
There is a feature in Matlab that enables you to submit jobs to clusters directly from your Matlab client (normal desktop Matlab). we were able to develop a Matlab-Viper plug-in that utilizes this feature and integrates Matlab with Viper to enable all our Matlab users to submit some Matlab jobs to Viper easily without the need to know much about HPC or Linux. Everything could be done from the normal desktop Matlab version that many users are already using.  
This guide should explain more on how to use viper through the Matlab viper plugin. In-general the toolbox that could utilise such integration is the Matlab parallel computing toolbox. we will try to explain the main concepts here and point you to some Mathworks tutorial that you could use and try on viper.
+
This guide should explain more about how to use Viper through the Matlab Viper plug-in. In general, the toolbox that could utilize such integration is the Matlab parallel computing toolbox. we will try to explain the main concepts here and point you to some MathWorks tutorials that you could use and try on our HPC.
*If you don't have Matlab-Viper plugin installed and tested on your Matlab contact help@hull.ac.uk or viper@hull.ac.uk and we will help you to install it and configure it.
+
 
*This is only available for Matlab 2017a , we will try to support it for all the upcoming versions starting from 2017a. if you have a special use case that requires the usage of older version you could check the possibility of creating this plugin for it by emailing us : viper@hull.ac.uk
+
*If you don't have the Matlab-Viper plug-in installed and tested on your Matlab contact [https://support.hull.ac.uk/ support portal] we will help you to install it and configure it.
* This link https://uk.mathworks.com/products/ineligible_programs.html  shows a list of Ineligible programs that couldn't run on Matlab distributed computing server through this plugin.
+
*This is only available for Matlab 2017a, we will try to support it for all the upcoming versions starting from 2017a. if you have a special use case that requires the usage of an older version you could check the possibility of creating this plug-in for it contact our [https://support.hull.ac.uk/ support portal].
 +
* This link https://uk.mathworks.com/products/ineligible_programs.html  shows a list of Ineligible programs that couldn't run on the Matlab distributed computing server through this plug-in.
  
 
==Matlab to Viper==
 
==Matlab to Viper==
 
===Main concepts===
 
===Main concepts===
Before we start we would like to introduce to you some basic concepts in order to be able to use this plugin efficiently.
+
Before we start we would like to introduce to you some basic concepts in order to be able to use this plug-in efficiently.
  
 
==== This plugin works by connecting 2 components together:====
 
==== This plugin works by connecting 2 components together:====
 
#'''Client:'''
 
#'''Client:'''
#:The client could run on your laptop or desktop computer. This is where you will run Matlab commands and submit your jobs.
+
#: The client could run on your laptop or desktop computer. This is where you will run Matlab commands and submit your jobs.
 
#'''Worker:'''
 
#'''Worker:'''
#:The worker is and instance of Matlab distributed computing enviornement that runs on Viper in order to perform a calculation for one of the clients. you could submit batch jobs from your clients that runs some simulations in parallel using functions like parfor, you could also run normal Matlab code on it.
+
#: The worker is an instance of a Matlab distributed computing environment that runs on Viper in order to perform a calculation for one of the clients. you could submit batch jobs from your clients that run some simulations in parallel using functions like ''parfor'', you could also run normal Matlab code on it.
  
 
==== limitations ====
 
==== limitations ====
submitting a job to Viper has a a lot of overhead. if you are running a small computing task it might take even longer to run on the cluster as there are a lot of time will be lost in communication and transferring your data to Viper then in sometimes your job could be queued and start running in a later time. however in many other cases it will show you a speedup and as a minimum you will be able to free up your client from doing this computation.
+
 
 +
Submitting a job to Viper has a lot of overhead. If you are running a small computing task it might take even longer to run on the cluster. However, in many other cases, it will show you a speed-up and as a minimum, you will be able to free up your client from doing this computation.
 +
 
 
===Run Matlab Job===
 
===Run Matlab Job===
using parallel tool box, you can run your Matlab code on viper using 2 modes:
+
 
===='''Batch job'''====
+
Using a parallel toolbox, you can run your Matlab code on Viper using 2 modes:
*This is the main way to utilize the Matlab-viper-plugin. This submit your job to Viper queuing system (SLURM) and send back the results to your client once everything is done.   
+
 
*Very useful for time consuming job that need hours or even days to finish. you will submit your job and you don't need to keep your Matlab running or even the whole computer could be turned off as all your simulation will be running on Viper.
+
====Batch job====
* if you want to know more about the job life cycles and different stages https://uk.mathworks.com/help/distcomp/how-parallel-computing-products-run-a-job.html#f3-11033
+
 
 +
* This is the main way to utilize the Matlab-viper-plugin. This submits your job to Viper queuing system (SLURM) and sends back the results to your client once everything is done.   
 +
* Very useful for a time-consuming job that needs hours or even days to finish. you will submit your job and you don't need to keep your Matlab running or even the whole computer could be turned off as all your simulations will be running on Viper.
 +
* If you want to know more about the job life cycles and different stages https://uk.mathworks.com/help/distcomp/how-parallel-computing-products-run-a-job.html
 +
 
*'''Create Matlab script'''
 
*'''Create Matlab script'''
*:this can be either a normal serial script or a parallel one that uses functions like parfor. if you have an exisiting script make sure that the following is done before running it:
+
*:This can be either a normal serial script or a parallel one that uses functions like parfor. if you have an existing script make sure that the following is done before running it:
** remove any parpool commands if any
+
** Remove any parpool commands if any
**modify the file paths if any is used in your script. consider that all your files will move to the cluster and run *:there so if your script contains a filepath that exisits only on your client it will not be able to find it there.  
+
** Modify the file paths if any is used in your script. consider that all your files will move to the cluster and run *: there so if your script contains a file path that exists only on your client it will not be able to find it there.  
 
*:example:  
 
*:example:  
 
*:use  
 
*:use  
Line 36: Line 48:
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> load ('/INPUT_DIRECTORY_NAME/INPUT_FILE_NAME')
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> load ('/INPUT_DIRECTORY_NAME/INPUT_FILE_NAME')
 
</pre>
 
</pre>
*'''Batch command''': This command begins an automated process that connects to the cluster, submits a job to the scheduler, and initializes MDCS. it will ask you to enter your user name and password. you must also make sure that you are using on the campus network or while using VPN
+
*'''Batch command''': This command begins an automated process that connects to the cluster, submits a job to the scheduler, and initializes MDCS. it will ask you to enter your username and password. you must also make sure that you are using the campus network or while using VPN
 
*For example if you submit a script to Viper with one input file:
 
*For example if you submit a script to Viper with one input file:
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> viper = parcluster()
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> viper = parcluster()
Line 42: Line 54:
 
</pre>
 
</pre>
 
:*Specify the name of your script without the “m” prefix. For instance use test, and not test.m
 
:*Specify the name of your script without the “m” prefix. For instance use test, and not test.m
:*The argument pool specified the number of workers you need for execution of the script. Note that the MATLAB adds one worker to the number of workers you specified in pool. So for instance if you specify 9 workers in the pool, then MATLAB will use 10 workers.
+
:*The argument pool specified the number of workers you need for the execution of the script. Note that MATLAB adds one worker to the number of workers you specified in the pool. So for instance, if you specify 9 workers in the pool, then MATLAB will use 10 workers.
:*The 4th Argument 'AttachedFiles' highlight that we are going to attache input file/files to this batch job. you can send multiple files by including them in braces. For Example<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> job = viper.batch('test', 'pool', 9, 'AttachedFiles', {input1, input2})</pre>
+
:*The 4th Argument 'AttachedFiles' highlights that we are going to attach input file(s) to this batch job. you can send multiple files by including them in braces. For Example<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;"> job = viper.batch('test', 'pool', 9, 'AttachedFiles', {input1, input2})</pre>
*When you finish working with this job and get all your outputs back. permanently delete its data and remove its reference from the workspace:
+
*When you finish working on this job and get all your outputs back. permanently delete its data and remove its reference from the workspace:
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;">  
 
<pre style="background-color: #f5f5dc; color: black; font-family: monospace, sans-serif;">  
 
delete(job)
 
delete(job)
 
clear job
 
clear job
 
</pre>
 
</pre>
== useful commands ==
+
==Useful commands==
below is some useful commands and its detailed offical documentation
+
below are some useful commands and their detailed official documentation
 
{| class="wikitable"
 
{| class="wikitable"
 
| style="width:25%" | <Strong>Training Area</Strong>
 
| style="width:25%" | <Strong>Training Area</Strong>
Line 59: Line 71:
 
|-
 
|-
 
| [[https://uk.mathworks.com/help/distcomp/job-monitor.html/XQuartz| Job Monitor]]  
 
| [[https://uk.mathworks.com/help/distcomp/job-monitor.html/XQuartz| Job Monitor]]  
| enable you to monitor all your jobs and its status
+
| enable you to monitor all your jobs and their status
 
|-
 
|-
 
| [[https://uk.mathworks.com/help/distcomp/index.html| Parallel Computing Toolbox]]
 
| [[https://uk.mathworks.com/help/distcomp/index.html| Parallel Computing Toolbox]]
Line 67: Line 79:
  
 
====Parallel pool====
 
====Parallel pool====
* Another mode of operation that is easier if you are testing piece of code or running a small job that you expect to finish in few minutes.  
+
* Another mode of operation that is easier is if you are testing a piece of code or running a small job that you expect to finish in a few minutes.  
* This requires a running connection to be in place between your computer and viper. at any point you shutdown your Matlab/Wifi or even your laptop everything will be lost and you will need to rerun your code/simulation.
+
* This requires a running connection to be in place between your computer and Viper. at any point you shut down your Matlab/Wifi or even your laptop everything will be lost and you will need to rerun your code/simulation.
  
 
== Further Information ==
 
== Further Information ==
Line 74: Line 86:
 
* [https://matlabacademy.mathworks.com/ Matlab online courses]
 
* [https://matlabacademy.mathworks.com/ Matlab online courses]
 
* [https://uk.mathworks.com/help/distcomp/batch.html/ Batch command documentation]
 
* [https://uk.mathworks.com/help/distcomp/batch.html/ Batch command documentation]
{|
+
 
|style="width:5%; border-width: 0" | [[File:icon_home.png]]
+
 
|style="width:95%; border-width: 0" |
+
 
* [[Main_Page|Home]]
+
 
* [[Applications|Application support]]
+
[[Main Page]]   /  [[FurtherTopics/FurtherTopics#Matlab| Further Topics]]
* [[General|General]]
+
-->
* [[Training|Training]]
 
* [[Programming|Programming support]]
 
|-
 
|}
 

Latest revision as of 09:36, 21 April 2023