AZUREML_MODEL_DIR

Eltohami, Hesham (H) 5 Reputation points
2023-05-02T22:24:41.93+00:00

I am trying to deploy a model into ACI, the scoring script has the following init() function:

User's image

The deployment fails with the following error:

File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/xyz1/code/Users/xyz/chapter12/score.py", line 8, in init
    model_path = os.path.join(os.getenv("AZUREML_MODEL_DIR"), "model/model.joblib")
  File "/anaconda/envs/azureml_py38/lib/python3.8/posixpath.py", line 76, in join
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

It seems that the AZUREML_MODEL_DIR variable does not get created during the deployment.

User's image

Any help is appreciated. Thanks a lot.

Hesham

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
3,341 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Eltohami, Hesham (H) 5 Reputation points
    2023-05-09T18:56:25.33+00:00

    @romungi-MSFT I finally was able to deploy the model into ACI

    I did the following changes to the scoring script:

    def init():
        global model
        #model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model.joblib')
        model_dir = Model.get_model_path(model_name='chapter12-hesham')
        model_path = os.path.join(model_dir, 'model.joblib')
        print(f"Loading model from {model_path}")
        model = joblib.load(model_path)
    

    The model was successfully loaded:

    User's image

    What I cannot understand is that when I used the AZUREML__MODEL__DIR, the deployment fails with following error:

    User's image

    The model_path is the same in both cases but fails to load when using the variable?

    1 person found this answer helpful.
    0 comments No comments

  2. Eltohami, Hesham (H) 5 Reputation points
    2023-05-03T15:30:21.4+00:00

    @romungi-MSFT thank you for your reply, I tried both folder name in the model path as you suggested

    however I am still the same error.

    Below is the code I used to register the model

    User's image

    Below is a screenshot of the artifact

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.