Run Config class
Represents configuration information for submitting a training run in Azure Machine Learning.
A ScriptRunConfig packages together the configuration information needed to submit a run in Azure ML, including the script, compute target, environment, and any distributed job-specific configs.
ScriptRunConfig(source_directory, script=None, arguments=None, run_config=None, _telemetry_values=None, compute_target=None, environment=None, distributed_job_config=None, resume_from=None, max_run_duration_seconds=2592000)
A local directory containing code files needed for a run.
The file path relative to the source_directory of the script to be run.
Optional command-line arguments to pass to the training script. Arguments are passed in pairs, for example, ['--arg1', arg1_val, '--arg2', arg2_val].
Optional run configuration to use.
Internal use only.
The compute target where training will happen. This can either be a ComputeTarget object, the name of an existing ComputeTarget, or the string "local". If no compute target is specified, your local machine will be used.
The environment to use for the run. If no environment is specified, azureml.core.runconfig.DEFAULT_CPU_IMAGE will be used as the Docker image for the run.
- azureml.core.runconfig.TensorflowConfiguration,azureml.core.runconfig.MpiConfiguration, or PyTorchConfiguration
For jobs that require additional distributed job-specific configurations.
The DataPath containing the checkpoint or model files from which to resume the experiment.
The maximum time allowed for the run. The system will attempt to automatically cancel the run if it took longer than this value. :type max_run_duration_seconds: int
The Azure Machine Learning SDK provides you with a series of interconnected classes, that are designed to help you train and compare machine learning models that are related by the shared problem that they are solving.
An Experiment acts as a logical container for these training runs. A ScriptRunConfig object is used to configure the information necessary for submitting a training run as part of an Experiment. When a run is submitted using a ScriptRunConfig object, the submit method returns an object of type ScriptRun. Then returned ScriptRun object gives you programmatic access to information about the training run. ScriptRun is a child class of Run.
The key concept to remember is that there are different configuration objects that are used to submit an experiment, based on what kind of run you want to trigger. The type of the configuration object then informs what child class of Run you get back from the submit method. When you pass a ScriptRunConfig object in a call to Experiment's submit method, you get back a ScriptRun object. Examples of other run objects returned include AutoMLRun (returned for an AutoML run) and PipelineRun (returned for a Pipeline run).
The following sample shows how to submit a training script on your local machine.
from azureml.core import ScriptRunConfig, RunConfiguration, Experiment # create or load an experiment experiment = Experiment(workspace, 'MyExperiment') # create or retrieve a compute target cluster = workspace.compute_targets['MyCluster'] # create or retrieve an environment env = Environment.get(ws, name='MyEnvironment') # configure and submit your training run config = ScriptRunConfig(source_directory='.', script='train.py', arguments=['--arg1', arg1_val, '--arg2', arg2_val], compute_target=cluster, environment=env) script_run = experiment.submit(config)
For more examples showing how to work with ScriptRunConfig, see:
these training notebooks
MAX_DURATION_SECONDS_DEFAULT = 2592000