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 use
setenv to 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
Every cluster profile that is not a local cluster has an
EnvironmentVariables property. 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
Use the Cluster Profile Manager to manage cluster profiles. To set the
EnvironmentVariables property for a cluster profile using the
Cluster Profile Manager, use the following steps.
Open the Cluster Profile Manager. To open the Cluster Profile Manager, on the Home tab in the Environment section, select Parallel > Create and Manage Clusters.
In the Cluster Profile Manager, select your cluster in the Cluster Profile list. For this example, select the
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.
Click Done to save the profile settings.
For more information about the Cluster Profile Manager, see Customize 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
EnvironmentVariables property 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 use
batchto 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 use
batchto 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.