Skip to content

Instantly share code, notes, and snippets.

@csiebler
Created May 3, 2021 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csiebler/60eb01de4d2552e9aa85e292e48b4a62 to your computer and use it in GitHub Desktop.
Save csiebler/60eb01de4d2552e9aa85e292e48b4a62 to your computer and use it in GitHub Desktop.
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