|  | 
|  | 1 | +# 06-run-pytorch-data.py | 
|  | 2 | +from azureml.core import Workspace | 
|  | 3 | +from azureml.core import Experiment | 
|  | 4 | +from azureml.core import Environment | 
|  | 5 | +from azureml.core import ScriptRunConfig | 
|  | 6 | +from azureml.core import Dataset | 
|  | 7 | + | 
|  | 8 | +if __name__ == "__main__": | 
|  | 9 | +    ws = Workspace.from_config() | 
|  | 10 | +    datastore = ws.get_default_datastore() | 
|  | 11 | +    dataset = Dataset.File.from_files(path=(datastore, 'datasets/cifar10')) | 
|  | 12 | + | 
|  | 13 | +    experiment = Experiment(workspace=ws, name='day1-experiment-data') | 
|  | 14 | + | 
|  | 15 | +    config = ScriptRunConfig( | 
|  | 16 | +        source_directory='./src', | 
|  | 17 | +        script='train.py', | 
|  | 18 | +        compute_target='cpu-cluster', | 
|  | 19 | +        arguments=[ | 
|  | 20 | +            '--data_path', dataset.as_named_input('input').as_mount(), | 
|  | 21 | +            '--learning_rate', 0.003, | 
|  | 22 | +            '--momentum', 0.92], | 
|  | 23 | +    ) | 
|  | 24 | +    # set up pytorch environment | 
|  | 25 | +    env = Environment.from_conda_specification( | 
|  | 26 | +        name='pytorch-env', | 
|  | 27 | +        file_path='./environments/pytorch-env.yml' | 
|  | 28 | +    ) | 
|  | 29 | +    config.run_config.environment = env | 
|  | 30 | + | 
|  | 31 | +    run = experiment.submit(config) | 
|  | 32 | +    aml_url = run.get_portal_url() | 
|  | 33 | +    print("Submitted to compute cluster. Click link below") | 
|  | 34 | +    print("") | 
|  | 35 | +    print(aml_url) | 
0 commit comments