Cheat Sheet
#
Basic setup#
Connect to workspaceThe workspace object is the fundamental handle on your Azure ML assets and is used
throughout (often simply referred to by ws
).
For more details: Workspaces
#
Connect to compute targetSample usage.
For more details: Compute Target
#
Prepare Python environmentYou can use a pip requirements.txt
file or a Conda env.yml
file to define a Python environment on your compute.
You can also use docker images to prepare your environments.
Sample usage.
For more details: Environment
#
Submit codeTo run code in Azure ML you need to:
- Configure: Configuration includes specifying the code to run, the compute target to run on and the Python environment to run in.
- Submit: Create or reuse an Azure ML Experiment and submit the run.
#
ScriptRunConfigA typical directory may have the following structure:
To run $ (env) python <path/to/code>/script.py [arguments]
on a remote compute
cluster target: ComputeTarget
with an environment env: Environment
we can use
the ScriptRunConfig
class.
For more details on arguments: Command line arguments
info
compute_target
: If not provided the script will run on your local machine.environment
: If not provided, uses a default Python environment managed by Azure ML. See Environment for more details.
#
CommandsIt is possible to provide the explicit command to run.
For more details: Commands
#
ExperimentTo submit this code, create an Experiment
: a light-weight container that helps to
organize our submissions and keep track of code (See Run History).
This link will take you to the Azure ML Studio where you can monitor your run.
For more details: ScriptRunConfig
#
Sample usageHere is a fairly typical example using a Conda environment to run a training
script train.py
on our local machine from the command line.
Suppose you want to run this on a GPU in Azure.
#
Distributed GPU TrainingAdapt your ScriptRunConfig
to enable distributed GPU training.
info
mcr.microsoft.com/azureml/openmpi3.1.2-cuda10.1-cudnn7-ubuntu18.04
is a docker image with OpenMPI. This is required for distributed training on Azure ML.MpiConfiguration
is where you specify the number of nodes and GPUs (per node) you want to train on.
For more details: Distributed GPU Training
#
Connect to dataTo work with data in your training scripts using your workspace ws
and its default datastore:
For more details see: Data
Pass this to your training script as a command line argument.