Access Cloud Cluster from MATLAB

When your cloud cluster is running, you access it and workers in the same way you access a cluster in your own onsite network. You can discover clusters on Amazon EC2 from your desktop MATLAB. You can also import cluster profiles or use parallel computing functions to identify available clusters for creating and submitting jobs.

Discover Clusters

You can let MATLAB discover clusters for you. You need a working network connection between the client and the Cloud Center web services running in

  1. Use either of the following to discover clusters available for you to use:

    • On the Home tab in the Environment section, select Parallel > Discover Clusters.

    • In the Cluster Profile Manager, select Discover Clusters

    Both options open the Discover Clusters wizard, where you can search for MATLAB® Parallel Server™ clusters.

  2. Select On Amazon EC2 and click Next. MATLAB searches for clusters running on Amazon EC2. To access these clusters, you must provide your MathWorks Account login information. Clusters appear in the list as they are discovered.

  3. Select the name of the cluster you want to use, and click Next. On the next screen, click Finish. If you do not want to set the new cluster profile as your default, you can clear the check box. You can set the default cluster at any time later using the Parallel menu. Parallel applications in your MATLAB session can use the desired cloud cluster by default.

Import Cluster Profiles

You can use the Cluster Profile Manager to import any MATLAB cluster profile downloaded from the Cloud Center. The cluster does not have to be in your account.

  1. On your MATLAB desktop, select Parallel > Manage Cluster Profiles.

  2. Click Import in the toolbar.

  3. Navigate to the location where you saved the profile you downloaded from the Cloud Center, and select the profile with its .settings extension.

  4. Select the newly imported profile in the Profile Manager list of profiles, then click Set As Default in the toolbar. Setting a profile as a default allows your parallel computing code to use this profile and its cluster with minimal code changes.

Test Your Cloud Cluster with the Profile Validator

With your cloud cluster profile selected, you can test your cloud cluster by running a validation of the profile:

  1. If the profile manager is not already open, on your MATLAB desktop, select Parallel > Manage Cluster Profiles.

  2. Select the name of your cloud profile and click Validate in the toolbar. This automatically displays the Validation Results tab so you can view the tests in progress. A pop-up dialog box might require you to log in to your MathWorks account to validate your cluster profile.

With your cloud cluster profile set as your default, you can now run parallel computing applications on the cloud with functions such as parpool (and therefore parfor and spmd), batch, createJob, etc.

Access Cloud Clusters Using the Command-Line

Find Clusters on Cloud

As an alternative to downloading a profile and importing it through the Profile Manager, you can use the fetchCloudClusters function to create cluster objects in MATLAB for your own clusters on the cloud. A pop-up dialog box might require you to log in to your MathWorks account when you execute this command. If you have more than one cluster running on the cloud, fetchCloudClusters returns an array of cluster objects; if you have only one cluster running, it returns just a single object:

c = fetchCloudClusters

MJSComputeCloud Cluster Information

           Modified: true
          NumWorkers: 32
  JobStorageLocation: Database on
   ClusterMatlabRoot: /mnt/matlab
     OperatingSystem: unix

 - Assigned Jobs

      Number Pending: 0
       Number Queued: 0
      Number Running: 0
     Number Finished: 0

 - MJSComputeCloud Specific Properties

                Name: MyCluster
               State: online
      NumBusyWorkers: 0
      NumIdleWorkers: 32

Now you can use the cluster object to create jobs and tasks in the usual manner. For example:




You can also start and stop cloud clusters using the cluster object, using the functions start and shutdown. The function wait (cluster) enables you to wait to submit jobs until all cluster workers are available.

Use Downloaded Profile for Cloud Cluster

As an alternative to fetchCloudClusters, you can use the a profile downloaded from the Cloud Center to identify the cluster you want to access. For example, suppose you downloaded the profile settings file to a file named C:\temp\MyCluster.settings. You can access and use this profile programmatically with:

c = parcluster('MyProfile')

Then proceed to use this cluster for creating jobs or running parallel algorithms: