Search code examples
pythonazuredeploymentazureportalazure-machine-learning-service

How can I register in Azure ML Service a machine learning model trained locally?


I am trying out Azure Machine Learning Service for ML deployment.

I have already trained a model on a compute VM and saved it as pickle, and now would like to deploy it (I am using Python on Azure notebooks for the purpose as of now).

From the guide, it looks like I need to I need a run object to be existing in my session to execute the "model registration" step:

# register model 
model = run.register_model(model_name='my_model', model_path='outputs/my_model.pkl')
print(model.name, model.id, model.version, sep = '\t')

However, I haven't created any run object as I haven't executed any experiment for training, I am just starting off with my pickled model.

I also tried to register a model by uploading it via the Azure Portal (see screenshot below), but (as the model file is quite large, I assume) it fails with a ajax error 413. as in Unable to register an ONNX model in azure machine learning service workspace.

model registering

Is there any way to register and then deploy a pretrained pickled mode (without the need of submitting a run, if that makes sense)?


Solution

  • Model registration can be done with Model.register, without the need of using a run object

    model = Model.register(model_name='my_model', model_path='my_model.pkl', workspace = ws)
    

    for the deployment one can follow steps as outlined in the Azure ML service doc.