Local Deployment Azure ML failed with error

santra 6 Reputation points
2021-09-10T18:09:40.17+00:00

I am a beginner in the Azure. I am using this tutorial https://learn.microsoft.com/en-us/azure/machine-learning/how-to-deploy-and-where?tabs=python of setting a dummy script for a local web service but many errors are coming up. It is strange because I am using an h5 file (model involving Keras and tensor flow) in place of onxx file. I used the code

from azureml.core import Environment  
from azureml.core.model import InferenceConfig  
  
env = Environment(name="myenv")  
conda_dep = CondaDependencies()  
conda_dep.add_conda_package("tensorflow")  
conda_dep.add_conda_package("pip")  
conda_dep.add_pip_package("azureml-core")  
conda_dep.add_pip_package("azureml-contrib-services")  
conda_dep.add_pip_package("azureml.api")  
env.python.conda_dependencies=conda_dep  
inference_config = InferenceConfig(  
    environment=env,  
    source_directory="./source_dir",  
    entry_script="./echo_score.py",  

)

I am trying to deploy the model local using Webservice. But always getting some error. I have tried many times but does not work. I am always getting some error. It is bizarre.

$ conda update -n base -c defaults conda

Pip subprocess error:
ERROR: Could not find a version that satisfies the requirement azureml.api (from -r /azureml-environment-setup/condaenv.811vr6y8.requirements.txt (line 4)) (from versions: none)
ERROR: No matching distribution found for azureml.api (from -r /azureml-environment-setup/condaenv.811vr6y8.requirements.txt (line 4))

CondaEnvException: Pip failed

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
1,869 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
4,937 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. romungi-MSFT 32,766 Reputation points Microsoft Employee
    2021-09-13T07:04:56.04+00:00

    @santra The error indicates that the environment setup is not done or the start of the environment setup is failing. I think you need to add the following line since you are using conda package installation along with pip packages.

     from azureml.core.environment import CondaDependencies  
    

    You can also use this sample notebook for localwebservice deployment using Azure notebooks feature for ml.azure.com
    This notebook or repo can be cloned directly from the portal and can be run to deploy the webservice.

    1 person found this answer helpful.

  2. Javaria 1 Reputation point
    2021-11-23T14:06:07.737+00:00

    Hi I am trying to deploy Prophet Model.
    Model is logged as mlflow.prophet flavour.
    Here the code for deployment:

    import azureml
    import mlflow.azureml
    from azureml.core import Workspace
    from azureml.core.authentication import ServicePrincipalAuthentication
    from azureml.core.webservice import AciWebservice, Webservice
    
    
    
    principal_auth = ServicePrincipalAuthentication(tenant_id, principal_id, app_secret)
    workspace = Workspace.get(name=workspace_name, subscription_id=subscription_id, auth=principal_auth, resource_group=workspace_rg)
    model_image, azureml_model = mlflow.azureml.build_image(model_uri='runs:/016fc3f2d5c34c8eadbeb20ad16d3/082358timeseriesforecasting', workspace=workspace)
    model_image.wait_for_creation(show_output=True)
    

    When I am creating image from Model Artifact this error came :

    WebserviceException: WebserviceException:
    Message: Image creation polling reached non-successful terminal state, current state: Failed
    Error response from server:
    StatusCode: 400
    Message: Docker image build failed.
    InnerException None
    ErrorResponse
    {
    "error": {
    "message": "Image creation polling reached non-successful terminal state, current state: Failed\nError response from server:\nStatusCode: 400\nMessage: Docker image build failed."
    }
    }

    In Container logs error is shown below:

    [0mThe command '/bin/sh -c CONDA_ROOT_DIR=$(conda info --root) && if [ -n "$AZUREML_CONDA_ENVIRONMENT_PATH" ]; then conda env update -p "$AZUREML_CONDA_ENVIRONMENT_PATH" -f '/var/azureml-app/conda.yaml'; else conda env update -n base -f '/var/azureml-app/conda.yaml'; fi && conda clean -aqy && rm -rf /root/.cache/pip && rm -rf "$CONDA_ROOT_DIR/pkgs" && find "$CONDA_ROOT_DIR" -type d -name pycache -exec rm -rf {} +' returned a non-zero code: 137
    2021/11/23 12:21:39 Container failed during run: acb_step_0. No retries remaining.
    failed to run step ID: acb_step_0: exit status 137

    Run ID: cj58 failed after 6m19s. Error: failed during run, err: exit status 1

    I have tried different yaml dependencies even defaults but of no use.
    Do anyone have a clue what is wrong here? Any solution?

    0 comments No comments