Main Content

Set Environment Variables on Workers

Some computations use system environment variables, such as computations that require Amazon S3™ access. When you offload computations to workers using Parallel Computing Toolbox™, the client and workers can have different operating system environment variables. On the client, you can usesetenvto set environment variables. You can then copy environment variables from the client to the workers so that the workers perform computations in the same way as the client.

Set Environment Variables for Cluster Profile

每一个集群配置文件不是轨迹l cluster has anEnvironmentVariablesproperty. You can use this property to specify a list of environment variables to copy from the client to cluster workers. These environment variables are set on the workers for the duration of a job or parallel pool.

Screen shot of Cluster Profile Manager. The MyMJSProfile1 cluster profile is selected, and the Workers dialog is open.

Use the Cluster Profile Manager to manage cluster profiles. To set theEnvironmentVariablesproperty for a cluster profile using the Cluster Profile Manager, use the following steps.

  1. Open the Cluster Profile Manager. To open the Cluster Profile Manager, on theHometab in theEnvironmentsection, selectParallel>Create and Manage Clusters.

  2. In the Cluster Profile Manager, select your cluster in the Cluster Profile list. For this example, select theMyMJSProfile1cluster.

  3. Go to the Workers section. Add the names of environment variables you want to copy from the client to cluster workers. Use one name per line, with no commas or other delimiters. Any listed variables that are not set are not copied to the workers.

  4. ClickDoneto save the profile settings.

For more information about the Cluster Profile Manager, seeCustomize Startup Parameters(MATLAB Parallel Server).

Set Environment Variables for a Job or Pool

You can also copy environment variables from the client to workers programmatically for the duration of a job or a parallel pool. The names are added to theEnvironmentVariablesproperty specified in the parallel profile to form the complete list of environment variables. Any listed variables that are not set are not copied to the workers.

  • When you usecreateJoborbatchto create a job, you can specify the names of environment variables by using the'EnvironmentVariables'name-value pair argument. These environment variables are set on the workers when the job starts. When the job finishes, the environment variables are returned to their previous values.

  • When you usebatchto create a parallel pool, you can specify the names of environment variables by using the'EnvironmentVariables'name-value pair argument. These environment variables are set on the workers for the duration of the parallel pool.

See Also

||

Related Topics