Difference between revisions of "MATLAB Parallel Server in Red Cloud"

From CAC Documentation wiki
Jump to navigation Jump to search
Line 1: Line 1:
 
== Assumptions ==
 
== Assumptions ==
*The MATLAB R2016a client, including the Parallel Computing Toolbox (PCT), is installed on your local workstation.
+
*You are a member of the Cornell community with access to its MATLAB licenses.
*[[Red_Cloud#First_Time_Login | First time login]] has been completed.
+
*You are familiar with [[Red_Cloud | Red Cloud]] and its Eucalyptus console.
*[[Red_Cloud#How_to_Access_Red_Cloud_Resources.3F | Create key pair]] has been completed.
+
*The MATLAB R2016a client, including the [http://www.mathworks.com/products/parallel-computing/ Parallel Computing Toolbox] (PCT), is installed on your local workstation.
 +
*[[Red_Cloud#First_Time_Login | First time Red Cloud login]] has been completed.
 +
*[[Red_Cloud#How_to_Access_Red_Cloud_Resources.3F | Create a Red Cloud key pair]] has been completed.
  
 
== Create a Security Group ==
 
== Create a Security Group ==
 
In the Eucalyptus Management Console (for [https://euca4.cac.cornell.edu recdcloud-ith]), you need to create a Security Group for your MATLAB instances. Its purpose is to open up certain TCP ports so your client has proper access to your MDCS server(s).
 
In the Eucalyptus Management Console (for [https://euca4.cac.cornell.edu recdcloud-ith]), you need to create a Security Group for your MATLAB instances. Its purpose is to open up certain TCP ports so your client has proper access to your MDCS server(s).
  
Choose "Security Groups", then "Create a new Security Group", and set the following Rules. Note, to auto-fill <your client IP address>/32, you can select the "Use my IP address" link after entering either the Custom TCP port range or the standard SSH port. You must click "Add Rule" at the bottom of the page after making each new entry.
+
Choose "Security Groups", then "Create a new Security Group", and set the following Rules.
 +
Note, to auto-fill <your client IP address>/32, you can select the "Use my IP address" link
 +
after entering either the Custom TCP port range or the standard SSH port.
 +
You must click "Add Rule" at the bottom of the page after making each new entry.
 +
You must also click "Create Security Group" after adding all rules.
  
 
{| border="1" cellspacing="0" cellpadding="5" align="center" style="text-align:left;"
 
{| border="1" cellspacing="0" cellpadding="5" align="center" style="text-align:left;"
Line 40: Line 46:
  
 
* From the dashboard, click on the "Launch Instance" button.
 
* From the dashboard, click on the "Launch Instance" button.
* Select '''emi-b10e13b4''' on the "Image" screen. Click on the Next button.
+
* Select the '''Matlab-2016a''' instance ('''emi-b10e13b4''') on the "Image" screen in one of two ways:
 +
** Scroll to find the image and click it's "Select" button.
 +
** Enter '''emi-b10e13b4''' in the search box at the bottom and click the "Next" button.
 
* On the "Details" screen, select the desired instance type. '''One MATLAB worker will be started per CPU in the instance.''' Click on the Next button.
 
* On the "Details" screen, select the desired instance type. '''One MATLAB worker will be started per CPU in the instance.''' Click on the Next button.
 
* On the "Security" screen, select the ssh keypair you'd like to use to access the instance via ssh (optional), and select your MATLAB security group.
 
* On the "Security" screen, select the ssh keypair you'd like to use to access the instance via ssh (optional), and select your MATLAB security group.
Line 53: Line 61:
 
* Open Parallel > Manage Cluster Profiles.
 
* Open Parallel > Manage Cluster Profiles.
 
* Choose Add > Custom > MATLAB Job Scheduler (MJS).
 
* Choose Add > Custom > MATLAB Job Scheduler (MJS).
* Click OK, then Edit. Only the top three entries are required.
+
* In the warning dialog that comes up, click "OK".
*# Description, '''Red Cloud''' (or other name that you choose)
+
* In the lower right corner of the scheduler, click "Edit".
*# Host, '''128.84.8.XXX''' (where XXX matches the public address of your Red Cloud instance)
+
* Enter values for at least the top three values in the form:
*# Name, '''EC2_job_manager'''
+
*# Description: '''Red Cloud''' or another name of your choosing.
* Click Done, then Validate. As each stage completes, a green circle with a check mark in it should be displayed.
+
*# Host: '''128.84.8.XXX''' (where XXX matches the public address of your Red Cloud instance)
 +
*# Name: '''EC2_job_manager'''
 +
* Click "Done".  Click "Rename" in the toolbar to give a new scheduler a better name.  This name will appear in your MATLAB client.
 +
* Click "Validate" in the toolbar to ensure the scheduler is configured properly. As each stage completes, a green circle with a check mark in it should be displayed.
 +
* If the first validation stage fails, it is most likely because the Euca Security Group is not allowing access from your client's IP address:
 +
** Log into the Euca Console ([https://euca4.cac.cornell.edu redcloud-ith]) using a web browser on the same machine as your MATLAB client.
 +
** Choose the Security Group you created and try to add one of the above rules, finishing with "Use my IP address".
 +
** If you do not get the message "Rule already exists", go ahead and add all three of the above rules for your current IP address.
 +
** Wait a few minutes until the new rules take effect in your running instance (you may also want to restart your MATLAB client). Now your MATLAB cluster should be able to pass all the validation stages.
  
The most common reason for the first validation stage to fail is that the Euca Security Group is not allowing access from your client's IP address. Log into the Euca Console ([https://euca4.cac.cornell.edu redcloud-ith]) using a web browser on the same machine as your MATLAB client. Choose the Security Group you created and try to add one of the above rules, finishing with "Use my IP address". The answer should be "Rule already exists".  If not, then go ahead and add all three of the above rules for your current IP address. Wait a few minutes until the new rules take effect in your running instance (you may also want to restart your MATLAB client). Now your MATLAB cluster should be able to pass all the validation stages.
+
Finally, you can run this quick "Hello, world" test from the command line in your client.
 
+
In the first line, supply the name of your scheduler.  If you did not rename the scheduler when you created it, its name appears in the Cluster Profiles Manager dialog.
Finally, you can run this quick "Hello, world" test from the command line in your client:
 
  
 
  pool = parpool('Red Cloud')
 
  pool = parpool('Red Cloud')
  spmd; fprintf('Hello from lab %d of %d',labindex,numlabs); end
+
  spmd; fprintf('Hello from lab %d of %d', labindex, numlabs); end
 
  delete(pool)
 
  delete(pool)
  
 
The number of replies should equal the number of workers ("labs"), which by default is equal to the number of cores in your instance. Note that the labs are numbered starting from 1, not 0.
 
The number of replies should equal the number of workers ("labs"), which by default is equal to the number of cores in your instance. Note that the labs are numbered starting from 1, not 0.

Revision as of 19:01, 3 October 2016

Assumptions

Create a Security Group

In the Eucalyptus Management Console (for recdcloud-ith), you need to create a Security Group for your MATLAB instances. Its purpose is to open up certain TCP ports so your client has proper access to your MDCS server(s).

Choose "Security Groups", then "Create a new Security Group", and set the following Rules. Note, to auto-fill <your client IP address>/32, you can select the "Use my IP address" link after entering either the Custom TCP port range or the standard SSH port. You must click "Add Rule" at the bottom of the page after making each new entry. You must also click "Create Security Group" after adding all rules.

Protocol Port range Allow traffic from IP address
Custom TCP 14000 - 15000 <your client IP address>/32
Custom TCP 27000 - 28000 <your client IP address>/32
SSH (for terminal access) 22 - 22 <your client IP address>/32


If you wish, you can set the security group to allow access from a broader range of IP addresses. For example, if the allowed IP ranges are set to:

  • 128.84.0.0/16,
  • 128.253.0.0/16,
  • 132.236.0.0/16,
  • 192.35.82.0/24,
  • 192.122.235.0/24,
  • 192.122.236.0/24, and
  • 10.0.0.0/8

access is permitted from anywhere on Cornell network (reference). However, you should be aware that in this case, any Cornell user who has knowledge of the IP address and the cluster name will be able to submit MDCS jobs to your Red Cloud instance(s).

In general, if other users require access to your Red Cloud instance for their MDCS jobs--or if you will be accessing MDCS from multiple IP addresses--then it is probably best to add the extra IP addresses to the security group individually, in the same way as the first.

Start the MATLAB Cluster

Currently only one-node clusters are supported. However, a single node can support many workers, up to the total number of cores that you assigned to your instance. Multi-node cluster support is forthcoming.

In the Euca Console (redcloud-ith):

  • From the dashboard, click on the "Launch Instance" button.
  • Select the Matlab-2016a instance (emi-b10e13b4) on the "Image" screen in one of two ways:
    • Scroll to find the image and click it's "Select" button.
    • Enter emi-b10e13b4 in the search box at the bottom and click the "Next" button.
  • On the "Details" screen, select the desired instance type. One MATLAB worker will be started per CPU in the instance. Click on the Next button.
  • On the "Security" screen, select the ssh keypair you'd like to use to access the instance via ssh (optional), and select your MATLAB security group.
  • Click on "Launch Instance"
  • After the instance is running, the MATLAB cluster should be reachable at the public IP address of the instance within 2 minutes.

Note: after you finish using your MATLAB cluster, remember to stop or terminate the instance on the Euca Console to stop charges against your Red Cloud subscription.

Connect to Your MATLAB Cluster

Perform the following steps in your local MATLAB client:

  • Open Parallel > Manage Cluster Profiles.
  • Choose Add > Custom > MATLAB Job Scheduler (MJS).
  • In the warning dialog that comes up, click "OK".
  • In the lower right corner of the scheduler, click "Edit".
  • Enter values for at least the top three values in the form:
    1. Description: Red Cloud or another name of your choosing.
    2. Host: 128.84.8.XXX (where XXX matches the public address of your Red Cloud instance)
    3. Name: EC2_job_manager
  • Click "Done". Click "Rename" in the toolbar to give a new scheduler a better name. This name will appear in your MATLAB client.
  • Click "Validate" in the toolbar to ensure the scheduler is configured properly. As each stage completes, a green circle with a check mark in it should be displayed.
  • If the first validation stage fails, it is most likely because the Euca Security Group is not allowing access from your client's IP address:
    • Log into the Euca Console (redcloud-ith) using a web browser on the same machine as your MATLAB client.
    • Choose the Security Group you created and try to add one of the above rules, finishing with "Use my IP address".
    • If you do not get the message "Rule already exists", go ahead and add all three of the above rules for your current IP address.
    • Wait a few minutes until the new rules take effect in your running instance (you may also want to restart your MATLAB client). Now your MATLAB cluster should be able to pass all the validation stages.

Finally, you can run this quick "Hello, world" test from the command line in your client. In the first line, supply the name of your scheduler. If you did not rename the scheduler when you created it, its name appears in the Cluster Profiles Manager dialog.

pool = parpool('Red Cloud')
spmd; fprintf('Hello from lab %d of %d', labindex, numlabs); end
delete(pool)

The number of replies should equal the number of workers ("labs"), which by default is equal to the number of cores in your instance. Note that the labs are numbered starting from 1, not 0.