Azure Machine Learning Training SDK
raw JSON → 1.62.0 verified Fri May 01 auth: no python maintenance
The Azure Machine Learning Python SDK training package provides functionality for configuring, submitting, and managing machine learning training runs on Azure. It includes support for hyperparameter tuning (HyperDrive), automated ML (AutoML), and distributed training. Current version is 1.62.0, last updated in early 2025. Release cadence is monthly, aligned with the Azure ML SDK releases.
pip install azureml-train Common errors
error ModuleNotFoundError: No module named 'azureml.train' ↓
cause Missing azureml-train package or import path mismatch.
fix
Run: pip install azureml-train. Ensure import uses correct submodule, e.g., 'from azureml.train.hyperdrive import ...'.
error ImportError: cannot import name 'ScriptRunConfig' from 'azureml.train' ↓
cause ScriptRunConfig was moved to azureml.core in recent SDK versions.
fix
Change import to: from azureml.core import ScriptRunConfig
error AttributeError: module 'azureml.train.hyperdrive' has no attribute 'HyperDriveRunConfig' ↓
cause HyperDriveRunConfig was renamed to HyperDriveConfig.
fix
Use 'HyperDriveConfig' instead. Import: from azureml.train.hyperdrive import HyperDriveConfig
Warnings
breaking Azure ML SDK v2 is now preferred; v1 (azureml-train) is in maintenance mode. New features only for v2. ↓
fix Migrate to azure-ai-ml (v2). See Microsoft migration guide.
deprecated AutoMLConfig from azureml-train is deprecated in favor of azure-ai-ml automl. ↓
fix Use azure-ai-ml to create automated ML jobs.
gotcha ScriptRunConfig import changed from azureml.train to azureml.core in SDK v1.0.85. ↓
fix Always import ScriptRunConfig from azureml.core.
gotcha HyperDriveConfig replaces deprecated HyperDriveRunConfig. Using old name causes ImportError. ↓
fix Use from azureml.train.hyperdrive import HyperDriveConfig.
Imports
- HyperDriveConfig wrong
from azureml.train.hyperdrive import HyperDriveRunConfigcorrectfrom azureml.train.hyperdrive import HyperDriveConfig - AutoMLConfig wrong
from azureml.train.automl import AutoMLConfig (not from azureml.train or from azureml.core)correctfrom azureml.train.automl import AutoMLConfig - ScriptRunConfig wrong
from azureml.train import ScriptRunConfigcorrectfrom azureml.core import ScriptRunConfig
Quickstart
from azureml.core import Workspace, Experiment, ScriptRunConfig
from azureml.core.compute import ComputeTarget, AmlCompute
from azureml.core.compute_target import ComputeTargetException
from azureml.train.hyperdrive import HyperDriveConfig, PrimaryMetricGoal, choice
# Connect to workspace
ws = Workspace.from_config()
# Create a compute cluster (if not exists)
cluster_name = "cpu-cluster"
try:
compute_target = ComputeTarget(workspace=ws, name=cluster_name)
except ComputeTargetException:
compute_config = AmlCompute.provisioning_configuration(vm_size='STANDARD_D2_V2', max_nodes=4)
compute_target = ComputeTarget.create(ws, cluster_name, compute_config)
compute_target.wait_for_completion(show_output=True)
# Configure a hyperparameter sweep
exp = Experiment(ws, 'my-experiment')
src = ScriptRunConfig(source_directory='.', script='train.py', compute_target=compute_target)
hyperdrive_config = HyperDriveConfig(run_config=src,
hyperparameter_sampling=choice({'--lr': [0.01, 0.001]}),
primary_metric_name='accuracy',
primary_metric_goal=PrimaryMetricGoal.MAXIMIZE,
max_total_runs=4)
submitted_run = exp.submit(hyperdrive_config)
submitted_run.wait_for_completion(show_output=True)