6

I'm using Azure Machine Learning Service with the azureml-sdk python library.

I'm using azureml.core version 1.0.8

I'm following this https://learn.microsoft.com/en-us/azure/machine-learning/service/how-to-create-your-first-pipeline tutorial.

I've got it working when I use Azure Compute resources. But I would like to run it locally.

I get the following error

raise ErrorResponseException(self._deserialize, response)
azureml.pipeline.core._restclients.aeva.models.error_response.ErrorResponseException: (BadRequest) Response status code does not indicate success: 400 (Bad Request).
Trace id: [uuid], message: Can't build command text for [train.py], moduleId [uuid] executionId [id]: Assignment for parameter Target is not specified

My code looks like:

run_config = RunConfiguration()
compute_target = LocalTarget()
run_config.target = LocalTarget()    
run_config.environment.python.conda_dependencies = CondaDependencies(conda_dependencies_file_path='environment.yml')
run_config.environment.python.interpreter_path = 'C:/Projects/aml_test/.conda/envs/aml_test_env/python.exe'
run_config.environment.python.user_managed_dependencies = True
run_config.environment.docker.enabled = False

trainStep = PythonScriptStep(
    script_name="train.py",
    compute_target=compute_target,
    source_directory='.',
    allow_reuse=False,
    runconfig=run_config
)

steps = [trainStep]

# Build the pipeline
pipeline = Pipeline(workspace=ws, steps=[steps])
pipeline.validate()

experiment = Experiment(ws, 'Test')

# Fails, locally, works on Azure Compute
run = experiment.submit(pipeline)


# Works both locally and on Azure Compute
src = ScriptRunConfig(source_directory='.', script='train.py', run_config=run_config)
run = experiment.submit(src)

The train.py is a very simple self contained script only dependent on numpy that approximates pi.

Davide Fiocco
  • 5,350
  • 5
  • 35
  • 72
CodeMonkey
  • 3,418
  • 4
  • 30
  • 53

2 Answers2

9

Local compute cannot be used with ML Pipelines. Please see this article.

  • Thank you. I didn't understand that table as it should not be possible. – CodeMonkey Jan 23 '19 at 11:02
  • Wouldn't it be possible to configure your local computer as a "Remote VM"? Given you have a public IP and allow SSH connections. I can however not find anything on how to setup such a resource, did they shut this down? https://learn.microsoft.com/en-us/azure/machine-learning/how-to-set-up-training-targets#vm – maechler Jul 09 '20 at 10:29
  • 4
    see https://learn.microsoft.com/en-us/azure/machine-learning/concept-compute-target#train indeed – reim Mar 08 '21 at 13:33
-3

Training on you local machine (for instance during development) is possible and very easy according to the documentation: how-to-set-up-training-targets

I did this on my windows computer as follows:

Define the local environment:

sklearn_env = Environment("user-managed-env")
sklearn_env.python.user_managed_dependencies = True
# You can choose a specific Python environment by pointing to a Python path 
sklearn_env.python.interpreter_path = r'C:\Dev\tutorial\venv\Scripts\python.exe'

And compute_target='local' seems to be the magic word to direct a script to my local environment.

src = ScriptRunConfig(source_directory=script_folder,
script='train_iris.py',
arguments=[dataset.as_named_input('iris')],
compute_target='local',
environment=sklearn_env)

I will then need to make sure that my local environment has all the dependencies that the script needs.

Additionally I needed to install these packages on my local machine:

  • azureml-defaults
  • packaging
Martin Alexandersson
  • 1,269
  • 10
  • 12