Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Package existing model as container in Azure Machine Learning
from azureml.core import Workspace, Model
from azureml.core.model import InferenceConfig
from azureml.core.environment import Environment
from azureml.core.conda_dependencies import CondaDependencies
ws = Workspace.from_config()
env = Environment("inference-env")
env.docker.enabled = True
# Replace with your conda enviroment file
env.python.conda_dependencies = CondaDependencies("./conda.yml")
# Replace with your score.py
inference_config = InferenceConfig(entry_script="score.py", environment=env)
# Replace with your model
model = Model(ws, 'my-model')
package = Model.package(ws, [model], inference_config)
package.wait_for_creation(show_output=True)
print(f"Packaged model image: {package.location}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment