Yerel çalıştırmaları SDK v2'ye yükseltme
Yerel çalıştırmalar hem V1 hem de V2'de benzerdir. İşlem hedefini her iki sürümde de ayarlarken "yerel" dizesini kullanın.
Bu makalede SDK v1 ve SDK v2'deki senaryoların karşılaştırması verilmiştir.
Yerel çalıştırma gönderme
SDK v1
from azureml.core import Workspace, Experiment, Environment, ScriptRunConfig # connect to the workspace ws = Workspace.from_config() # define and configure the experiment experiment = Experiment(workspace=ws, name='day1-experiment-train') config = ScriptRunConfig(source_directory='./src', script='train.py', compute_target='local') # set up pytorch environment env = Environment.from_conda_specification( name='pytorch-env', file_path='pytorch-env.yml') config.run_config.environment = env run = experiment.submit(config) aml_url = run.get_portal_url() print(aml_url)
SDK v2
#import required libraries from azure.ai.ml import MLClient, command from azure.ai.ml.entities import Environment from azure.identity import DefaultAzureCredential #connect to the workspace ml_client = MLClient.from_config(DefaultAzureCredential()) # set up pytorch environment env = Environment( image='mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04', conda_file='pytorch-env.yml', name='pytorch-env' ) # define the command command_job = command( code='./src', command='train.py', environment=env, compute='local', ) returned_job = ml_client.jobs.create_or_update(command_job) returned_job
SDK v1 ve SDK v2'deki temel işlevlerin eşlemesi
SDK v1'deki işlevsellik | SDK v2'de kaba eşleme |
---|---|
experiment.submit | MLCLient.jobs.create_or_update |