AutoML ステップでパイプラインを開発し、生成されたアーティファクトを使用してモデルを登録しました。アーティファクトはシリアル化されたモデルであり、大きな単一ファイル model_data. pickle.load 関数を使用して、スコアリング ファイルの Init 関数でモデルを逆シリアル化しましたが、展開中に失敗しました。メインのノートブックでモデルを unpickle すると、問題なく動作しました。それは私を夢中にさせます。助けてください、皆さん!
AutoML-Pipeline.ipynb
automl_settings = {
"experiment_timeout_minutes": 30,
"primary_metric": 'AUC_weighted',
"max_concurrent_iterations": 3,
"max_cores_per_iteration": -1,
"enable_dnn": True,
"enable_early_stopping": True,
"validation_size": 0.3,
"verbosity": logging.INFO,
"enable_voting_ensemble": False,
"enable_stack_ensemble": False,
}
automl_config = AutoMLConfig(task = 'classification',
debug_log = 'automl_errors.log',
path = ".",
compute_target=compute_target,
training_data = train_ds,
label_column_name = target_column_name,
**automl_settings
)
metrics_output_name = 'metrics_output'
best_model_output_name = 'best_model_output'
metrics_data = PipelineData(name='metrics_data',
datastore=dstor,
pipeline_output_name=metrics_output_name,
training_output=TrainingOutput(type='Metrics'))
model_data = PipelineData(name='model_data',
datastore=dstor,
pipeline_output_name=best_model_output_name,
training_output=TrainingOutput(type='Model'))
automl_step = AutoMLStep(
name='automl_module',
automl_config=automl_config,
outputs=[metrics_data, model_data],
allow_reuse=False)
score_file_v_1_0_0.py
def init():
global model
model_path = os.path.join(os.getenv('AZUREML_MODEL_DIR'), 'model_data')
try:
with open(model_path, "rb" ) as f:
model = pickle.load(f)
except Exception as e:
logging_utilities.log_traceback(e, logger)
raise
AutoML-Pipeline.ipynb
model = Model(ws, 'AutoML-Product')
automl_env = Environment.from_conda_specification(name = 'automl_env', file_path = 'conda_env_v_1_0_0.yml')
inference_config=InferenceConfig(entry_script="scoring_file_v_1_0_0.py",environment=automl_env)
aciconfig=AciWebservice.deploy_configuration(cpu_cores=1,
memory_gb=1,
tags={'type': "automl_product"},
description='Product Classification')
aci_service=Model.deploy(ws, "automl-product-classification", [model], inference_config, aciconfig)
aci_service.wait_for_deployment(True)
エラー:
WebserviceException: WebserviceException: Message: Service deployment polling reached non-successful terminal state, current service state.
Error:
{
"code": "AciDeploymentFailed",
"statusCode": 400,
"message": "Aci Deployment failed with exception: Your scoring file's init() function restarts frequently. You can address the error by increasing the value of memory_gb in deployment_config.",
"details": [
{
"code": "ScoreInitRestart",
"message": "Your scoring file's init() function restarts frequently. You can address the error by increasing the value of memory_gb in deployment_config."
}
]
}
ノートブックでの正常な実行: AutoML-Pipeline.ipynb
import pickle
path=Model.get_model_path('AutoML-Product',None,ws)
with open(path, "rb" ) as f:
best_model = pickle.load(f)
best_model
>>>>>
PipelineWithYTransformations(Pipeline={'memory': None,
'steps': [('datatransformer',
DataTransformer(enable_dnn=True, enable_feature_sweeping=True, feature_sweeping_config={}, feature_sweeping_timeout=86400, featurization_config=None, force_text_dnn=False, is_cross_validation=False, is_onnx_compatible=False, observer=None, task='classification', working_dir='/mn...
with_std=True
)),
('LogisticRegression',
LogisticRegression(C=0.02811768697974228,
class_weight='balanced',
dual=False,
fit_intercept=True,
intercept_scaling=1,
l1_ratio=None,
max_iter=100,
multi_class='ovr',
n_jobs=-1,
penalty='l2',
random_state=None,
solver='saga',
tol=0.0001,
verbose=0,
warm_start=False))],
'verbose': False},
y_transformer={},
y_transformer_name='LabelEncoder')