question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Model deployment failed when using an environment prebuilt from a Dockerfile

See original GitHub issue
  • Package Name: azureml.core.model
  • Package Version: 1.43.0
  • Operating System: ubuntu20.04
  • Python Version: Python 3.7.9

Describe the bug We used a custom environment built from Dockerfile as the environment for model serving (named as my-model-serving-env), but the model deployment failed with error of:

  File "/opt/miniconda/lib/python3.7/site-packages/azureml/core/model.py", line 2222, in validate_configuration
    or not self.environment.docker.base_image.startswith('mcr.microsoft.com/azureml')):
AttributeError: 'NoneType' object has no attribute 'startswith'

Here’s the Dockerfile for building the environment:

FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:20220504.v1

COPY myapplication-1.0.0-py2.py3-none-any.whl /local-wheels/
COPY requirements.txt .
RUN python -m pip install --upgrade pip && \
    python -m pip install /local-wheels/myapplication-1.0.0-py2.py3-none-any.whl && \
    python -m pip install -r requirements.txt && \
    rm requirements.txt

CMD ["/bin/bash"]

Here’s the requirements.txt:

azureml-defaults

Below is the code snippet of model deployment:

def getMyModel(ws, name, id):
    registered_models = Model.list(
        workspace=ws,
        name=name,
    )
    for m in registered_models:
        if m.id == id:
            return m 
    return None

run = Run.get_context()
ws = run.experiment.workspace

# Get the prebuilt registered environment my-model-serving-env:
env = Environment.get(ws, 'my-model-serving-env')

model_inference_config = InferenceConfig(
    environment=env,
    source_directory=".",
    entry_script="./_my_model_score.py",
)

deployment_config = AciWebservice.deploy_configuration(
    cpu_cores=0.5, memory_gb=1, auth_enabled=True
)

model_to_deploy = getMyModel(ws, "my_model", my_model_id)
if model_to_deploy != None:
    service = Model.deploy(
        ws,
        "mymodelservice",
        [model_to_deploy],
        model_inference_config,
        deployment_config,
        overwrite=True,
    )
    service.wait_for_deployment(show_output=True)
    print("model deployed.")
else:
    print(f"[Error]: my_model with ID {my_model_id} not found.")

It seems that the docker.base_image of the environment is not properly populated for the environments built from Dockerfiles (even if the base image is specified as FROM mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04:20220504.v1 in the Dockerfile).

To Reproduce Steps to reproduce the behavior:

  1. Build the environment using the Dockerfile and the requirements.txt (as well as the application wheel file which provides implementation needed for model serving, but the application wheel file has nothing to do with the error reported).
  2. Deploy the model to an endpoint using the above Python code snippet.

Expected behavior The code for checking the base_image of the environment (base_image.startswith('mcr.microsoft.com/azureml')) in azureml.core.model.py shouldn’t fail.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
swathipilcommented, Jul 29, 2022

@Rainfarm - Thanks for opening an issue! Directing this to @azureml-github to investigate as soon as possible.

1reaction
Rainfarmcommented, Dec 2, 2022

We’ve already migrated to SDK v2, and don’t need the fix of this issue. Thank you @luigiw!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot prebuilt docker images - Azure Machine Learning
Troubleshooting steps for using prebuilt Docker images for inference. ... If model deployment fails, you won't see logs in Azure Machine ...
Read more >
Best practices for writing Dockerfiles - Docker Documentation
Best practices for writing Dockerfiles. This document covers recommended best practices and methods for building efficient images.
Read more >
Extend a Prebuilt Container - Amazon SageMaker
To run your own training model using the SageMaker containers, build a Docker container through a SageMaker Notebook instance.
Read more >
Pre-built containers for prediction and explanation | Vertex AI
Vertex AI provides Docker container images that you run as pre-built ... To see an example of using a pre-built container when you...
Read more >
How to include files outside of Docker's build context?
Same mental model here, think that all the files under this directory are ... Alternatively, use docker as your fundamental code deployment artifact...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found