You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/machine-learning/how-to-use-batch-model-deployments.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,7 +49,7 @@ In this article, you use a batch endpoint to deploy a machine learning model tha
49
49
50
50
# [Azure CLI](#tab/cli)
51
51
52
-
First, connect to the Azure Machine Learning workspace where you'll work.
52
+
First, connect to the Azure Machine Learning workspace where you work.
53
53
54
54
If you haven't already set the defaults for the Azure CLI, save your default settings. To avoid passing in the values for your subscription, workspace, resource group, and location multiple times, run this code:
55
55
@@ -60,7 +60,7 @@ az configure --defaults workspace=<workspace> group=<resource-group> location=<l
60
60
61
61
# [Python](#tab/python)
62
62
63
-
The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning. In this section, you connect to the workspace in which you'll perform deployment tasks.
63
+
The workspace is the top-level resource for Azure Machine Learning, providing a centralized place to work with all the artifacts you create when you use Azure Machine Learning. In this section, you connect to the workspace in which you perform deployment tasks.
64
64
65
65
1. Import the required libraries:
66
66
@@ -196,12 +196,12 @@ A model deployment is a set of resources required for hosting the model that doe
196
196
* A registered model in the workspace
197
197
* The code to score the model
198
198
* An environment with the model's dependencies installed
199
-
* The pre-created compute and resource settings
199
+
* The precreated compute and resource settings
200
200
201
201
1. Begin by registering the model to be deployed—a Torch model for the popular digit recognition problem (MNIST). Batch Deployments can only deploy models that are registered in the workspace. You can skip this step if the model you want to deploy is already registered.
202
202
203
203
> [!TIP]
204
-
> Models are associated with the deployment, rather than with the endpoint. This means that a single endpoint can serve different models (or model versions) under the same endpoint, provided that the different models (or model versions) are deployed in different deployments.
204
+
> Models are associated with the deployment, rather than with the endpoint. This means that a single endpoint can serve different models (or model versions) under the same endpointaslongas the different models (or model versions) are deployed in different deployments.
205
205
206
206
# [Azure CLI](#tab/cli)
207
207
@@ -231,13 +231,13 @@ A model deployment is a set of resources required for hosting the model that doe
231
231
> For MLflow models, Azure Machine Learning automatically generates the scoring script, so you're not required to provide one. If your model is an MLflow model, you can skip this step. For more information about how batch endpoints work with MLflow models, see the article [Using MLflow models in batch deployments](how-to-mlflow-batch.md).
232
232
233
233
> [!WARNING]
234
-
> If you're deploying an Automated machine learning (AutoML) model under a batch endpoint, note that the scoring script that AutoML provides only works for online endpoints and is not designed for batch execution. For information on how to create a scoring script for your batch deployment, see [Author scoring scripts for batch deployments](how-to-batch-scoring-script.md).
234
+
> If you're deploying an Automated machine learning (AutoML) model under a batch endpoint, note that the scoring script that AutoML provides only works for online endpoints and isn't designed for batch execution. For information on how to create a scoring script for your batch deployment, see [Author scoring scripts for batch deployments](how-to-batch-scoring-script.md).
1. Create an environment where your batch deployment will run. The environment should include the packages `azureml-core`and`azureml-dataset-runtime[fuse]`, which are required by batch endpoints, plus any dependency your code requires for running. In this case, the dependencies have been captured in a `conda.yaml`file:
240
+
1. Create an environment where your batch deployment runs. The environment should include the packages `azureml-core`and`azureml-dataset-runtime[fuse]`, which are required by batch endpoints, plus any dependency your code requires for running. In this case, the dependencies have been captured in a `conda.yaml`file:
241
241
242
242
_deployment-torch/environment/conda.yaml_
243
243
@@ -250,7 +250,7 @@ A model deployment is a set of resources required for hosting the model that doe
250
250
251
251
# [Azure CLI](#tab/cli)
252
252
253
-
The environment definition will be included in the deployment definition itself as an anonymous environment. You'll see in the following lines in the deployment:
253
+
The environment definition isincluded in the deployment definition itself as an anonymous environment. You see in the following lines in the deployment:
@@ -285,7 +285,7 @@ A model deployment is a set of resources required for hosting the model that doe
285
285
---
286
286
287
287
> [!WARNING]
288
-
> Curated environments are not supported in batch deployments. You need to specify your own environment. You can always use the base image of a curated environment as yours to simplify the process.
288
+
> Curated environments aren't supported in batch deployments. You need to specify your own environment. You can always use the base image of a curated environment as yours to simplify the process.
289
289
290
290
1. Create a deployment definition
291
291
@@ -303,17 +303,17 @@ A model deployment is a set of resources required for hosting the model that doe
303
303
|`endpoint_name`| The name of the endpoint to create the deployment under. |
304
304
|`model`| The model to be used for batch scoring. The example defines a model inline using `path`. This definition allows model files to be automatically uploaded and registered with an autogenerated name and version. See the [Model schema](./reference-yaml-model.md#yaml-syntax) for more options. As a best practice for production scenarios, you should create the model separately and reference it here. To reference an existing model, use the `azureml:<model-name>:<model-version>` syntax. |
305
305
|`code_configuration.code`| The local directory that contains all the Python source code to score the model. |
306
-
|`code_configuration.scoring_script`| The Python filein the `code_configuration.code` directory. This file must have an `init()` function and a `run()` function. Use the `init()` function forany costly or common preparation (for example, to load the model in memory). `init()`will be called only once at the start of the process. Use `run(mini_batch)` to score each entry; the value of `mini_batch`is a list of file paths. The `run()` function should return a pandas DataFrame or an array. Each returned element indicates one successful run of input element in the `mini_batch`. For more information on how to author a scoring script, see [Understanding the scoring script](how-to-batch-scoring-script.md#understanding-the-scoring-script). |
307
-
|`environment`| The environment to score the model. The example defines an environment inline using `conda_file`and`image`. The `conda_file` dependencies will be installed on top of the `image`. The environment will be automatically registered with an autogenerated name and version. See the [Environment schema](./reference-yaml-environment.md#yaml-syntax) for more options. As a best practice for production scenarios, you should create the environment separately and reference it here. To reference an existing environment, use the `azureml:<environment-name>:<environment-version>` syntax. |
306
+
|`code_configuration.scoring_script`| The Python filein the `code_configuration.code` directory. This file must have an `init()` function and a `run()` function. Use the `init()` function forany costly or common preparation (for example, to load the model in memory). `init()`is called only once at the start of the process. Use `run(mini_batch)` to score each entry; the value of `mini_batch`is a list of file paths. The `run()` function should return a pandas DataFrame or an array. Each returned element indicates one successful run of input element in the `mini_batch`. For more information on how to author a scoring script, see [Understanding the scoring script](how-to-batch-scoring-script.md#understanding-the-scoring-script). |
307
+
|`environment`| The environment to score the model. The example defines an environment inline using `conda_file`and`image`. The `conda_file` dependencies are installed on top of the `image`. The environment is automatically registered with an autogenerated name and version. See the [Environment schema](./reference-yaml-environment.md#yaml-syntax) for more options. As a best practice for production scenarios, you should create the environment separately and reference it here. To reference an existing environment, use the `azureml:<environment-name>:<environment-version>` syntax. |
308
308
|`compute`| The compute to run batch scoring. The example uses the `batch-cluster` created at the beginning and references it using the `azureml:<compute-name>` syntax. |
309
309
|`resources.instance_count`| The number of instances to be used for each batch scoring job. |
310
310
|`settings.max_concurrency_per_instance`| The maximum number of parallel `scoring_script` runs per instance. |
311
311
|`settings.mini_batch_size`| The number of files the `scoring_script` can process in one `run()` call. |
312
-
|`settings.output_action`| How the output should be organized in the output file. `append_row`will mergeall`run()` returned output results into one single file named `output_file_name`. `summary_only` won't merge the output results and will only calculate `error_threshold`. |
312
+
|`settings.output_action`| How the output should be organized in the output file. `append_row`mergesall`run()` returned output results into one single file named `output_file_name`. `summary_only` won't merge the output results and will only calculate `error_threshold`. |
313
313
|`settings.output_file_name`| The name of the batch scoring output filefor`append_row``output_action`. |
314
314
|`settings.retry_settings.max_retries`| The number of max tries for a failed `scoring_script``run()`. |
315
315
|`settings.retry_settings.timeout`| The timeout in seconds for a `scoring_script``run()`for scoring a mini batch. |
316
-
|`settings.error_threshold`| The number of inputfile scoring failures that should be ignored. If the error count for the entire input goes above this value, the batch scoring job will be terminated. The example uses `-1`, which indicates that any number of failures is allowed without terminating the batch scoring job. |
316
+
|`settings.error_threshold`| The number of inputfile scoring failures that should be ignored. If the error count for the entire input goes above this value, the batch scoring job is terminated. The example uses `-1`, which indicates that any number of failures is allowed without terminating the batch scoring job. |
|`settings.environment_variables`| Dictionary of environment variable name-value pairs to setfor each batch scoring job. |
319
319
@@ -366,9 +366,9 @@ A model deployment is a set of resources required for hosting the model that doe
366
366
367
367
1. For __Output file name__, ensure the batch scoring output fileis the one you need. Default is`predictions.csv`.
368
368
369
-
1. For __Mini batch size__, adjust the size of the files that will be included on each mini-batch. This size will control the amount of data your scoring script receives per batch.
369
+
1. For __Mini batch size__, adjust the size of the files that will be included on each mini-batch. This size controls the amount of data your scoring script receives per batch.
370
370
371
-
1. For __Scoring timeout (seconds)__, ensure you're giving enough time for your deployment to score a given batch of files. If you increase the number of files, you usually have to increase the timeout value too. More expensive models (like those based on deep learning), may require high values in this field.
371
+
1. For __Scoring timeout (seconds)__, ensure you're giving enough time for your deployment to score a given batch of files. If you increase the number of files, you usually have to increase the timeout value too. More expensive models (like those based on deep learning) might require high values in this field.
372
372
373
373
1. For __Max concurrency per instance__, configure the number of executors you want to have for each compute instance you get in the deployment. A higher number here guarantees a higher degree of parallelization but it also increases the memory pressure on the compute instance. Tune this value altogether with __Mini batch size__.
374
374
@@ -383,7 +383,7 @@ A model deployment is a set of resources required for hosting the model that doe
383
383
1. Select the compute cluster you created in a previous step.
384
384
385
385
> [!WARNING]
386
-
> Azure Kubernetes cluster are supported in batch deployments, but only when created using the Azure Machine Learning CLIor Python SDK.
386
+
> Azure Kubernetes clusters are supported in batch deployments, but only when created using the Azure Machine Learning CLIor Python SDK.
387
387
388
388
1. For __Instance count__, enter the number of compute instances you want for the deployment. In this case, use 2.
389
389
@@ -465,12 +465,12 @@ __Outputs__: Results from your model, stored as files in Azure Storage. By defau
465
465
466
466
Invoking a batch endpoint triggers a batch scoring job. The job `name`is returned from the invoke response and can be used to track the batch scoring progress. When running models for scoring in batch endpoints, you need to specify the path to the input data so that the endpoints can find the data you want to score. The following example shows how to start a new job over a sample data of the MNIST dataset stored in an Azure Storage Account.
467
467
468
-
You can run and invoke a batch endpoint using Azure CLI, Azure Machine Learning SDK, orREST endpoints. For more details about these options, see [Create jobs andinput data for batch endpoints](how-to-access-data-batch-endpoints-jobs.md).
468
+
You can run and invoke a batch endpoint using Azure CLI, Azure Machine Learning SDK, orREST endpoints. For more information about these options, see [Create jobs andinput data for batch endpoints](how-to-access-data-batch-endpoints-jobs.md).
469
469
470
470
> [!NOTE]
471
471
> __How does parallelization work?__
472
472
>
473
-
> Batch deployments distribute work at the file level, which means that a folder containing 100 files with mini-batches of 10 files will generate 10 batches of 10 files each. Notice that this happens regardless of the size of the files involved. If your files are too big to be processed in large mini-batches, we suggest that you either split the files into smaller files to achieve a higher level of parallelism or you decrease the number of files per mini-batch. Currently, batch deployments can't account for skews in a file's size distribution.
473
+
> Batch deployments distribute work at the file level, which means that a folder containing 100 files with mini-batches of 10 files will generate 10 batches of 10 files each. Notice that this happens regardless of the size of the files involved. If your files are too large to be processed in large mini-batches, we suggest that you either split the files into smaller files to achieve a higher level of parallelism or you decrease the number of files per mini-batch. Currently, batch deployments can't account for skews in a file's size distribution.
474
474
475
475
# [Azure CLI](#tab/cli)
476
476
@@ -636,7 +636,7 @@ Once you've identified the data store you want to use, configure the output as f
636
636
---
637
637
638
638
> [!WARNING]
639
-
> You must use a unique output location. If the output file exists, the batch scoring job will fail.
639
+
> You must use a unique output location. If the output file exists, the batch scoring job fails.
640
640
641
641
> [!IMPORTANT]
642
642
> Unlike inputs, outputs can be stored only in Azure Machine Learning data stores that run on blob storage accounts.
@@ -787,9 +787,9 @@ In this example, you add a second deployment that uses a __model built with Kera
787
787
788
788
1. For __Output file name__, ensure the batch scoring output fileis the one you need. Default is`predictions.csv`.
789
789
790
-
1. For __Mini batch size__, adjust the size of the files that will be included in each mini-batch. This will control the amount of data your scoring script receives for each batch.
790
+
1. For __Mini batch size__, adjust the size of the files that will be included in each mini-batch. This controls the amount of data your scoring script receives for each batch.
791
791
792
-
1. For __Scoring timeout (seconds)__, ensure you're giving enough time for your deployment to score a given batch of files. If you increase the number of files, you usually have to increase the timeout value too. More expensive models (like those based on deep learning), may require high values in this field.
792
+
1. For __Scoring timeout (seconds)__, ensure you're giving enough time for your deployment to score a given batch of files. If you increase the number of files, you usually have to increase the timeout value too. More expensive models (like those based on deep learning) might require high values in this field.
793
793
794
794
1. For __Max concurrency per instance__, configure the number of executors you want to have for each compute instance you get in the deployment. A higher number here guarantees a higher degree of parallelization but it also increases the memory pressure on the compute instance. Tune this value altogether with __Mini batch size__.
0 commit comments