Main Content

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
===================================

            Profile: 
           Modified: true
               Host: ec2-107-21-71-51.compute-1.amazonaws.com
          NumWorkers: 32
  JobStorageLocation: Database on MyCluster@ec2-107-21-71-51.compute-1.amazonaws.com
   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:

parpool(c,8)

or

createJob(c)

If you are the cluster owner, you can also start and stop cloud clusters using the cluster object, using the functions start (Parallel Computing Toolbox) and shutdown (Parallel Computing Toolbox). You are the cluster owner if you created the cluster. The function wait (cluster) (Parallel Computing Toolbox) 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 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:

parallel.importProfile('C:\temp\MyCluster.settings')
c = parcluster('MyProfile')

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

parpool(c,2)

or

createJob(c)

Related Topics