Я пытаюсь развернуть свою модель машинного обучения в AciWebservice Azure, чтобы предоставить конечные точки для дальнейшего использования. Но это показывает мне статус 504 ошибка с DeploymentTimedOut. Локально моя модель работает нормально. Это мой предсказание.py
%%writefile prediction.py
import json
import numpy as np
import os
import pickle
from sklearn.externals import joblib
from sklearn.linear_model import LogisticRegression
from azureml.core.model import InferenceConfig
from azureml.core.conda_dependencies import CondaDependencies
from azureml.core.model import Model
from azureml.core.environment import Environment
from azureml.core.webservice import LocalWebservice, Webservice
def init():
global model
# retrieve the path to the model file using the model name
model_path = Model.get_model_path('prediction_model')
model = joblib.load(model_path)
def run(raw_data):
data = np.array(json.loads(raw_data)['data'])
# make prediction
y_hat = model.predict(data)
return json.dumps(y_hat.tolist())
, и здесь идет речь о среде
myenv = Environment(name="myenv")
myenv.docker.enabled = True
myenv.docker.base_image = "mcr.microsoft.com/azureml/o16n-sample-user-base/ubuntu-miniconda"
myenv.docker.base_image_registry.address = "shohozds.azurecr.io"
myenv.docker.base_image_registry.username = "farhad"
myenv.docker.base_image_registry.password = "*********************"
myenv.inferencing_stack_version = "latest"
conda_dep = CondaDependencies()
conda_dep.add_pip_package("azureml-defaults")
myenv.python.conda_dependencies=conda_dep
myenv.register(workspace=ws)
Использование этой среды в InferenceConfig
inference_config = InferenceConfig(entry_script="prediction.py",
environment=envs['myenv'])
Конфигурация AciWebservice
deployment_config = AciWebservice.deploy_configuration(cpu_cores = 1, memory_gb = 1)
А теперь развертывание модели
service = Model.deploy(ws, "myservice", [model], inference_config, deployment_config)
service.wait_for_deployment(show_output = True)
print(service.state)
Но я сталкиваюсь с этой ошибкой
"code": "DeploymentTimedOut",
"statusCode": 504,
Это полный след
ERROR - Service deployment polling reached non-successful terminal state, current service state: Unhealthy
Operation ID: 0e37b930-2707-4d6b-92b0-2203d1c45978
More information can be found using '.get_logs()'
Error:
{
"code": "DeploymentTimedOut",
"statusCode": 504,
"message": "The deployment operation polling has TimedOut. The service creation is taking longer than our normal time. We are still trying to achieve the desired state for the web service. Please check the webservice state for the current webservice health. You can run print(service.state) from the python SDK to retrieve the current state of the webservice."
}