Mlflow部署的model server报错BAD_REQUEST

这边部署了一个mlflow里面的model作为server,但是但我call它的invocations的预测方法的时候报错

 用这个命令进行部署的

mlflow models serve -m models:/model_name/1 --no-conda -p 5006 -h 0.0.0.0

{

    "error_code": "BAD_REQUEST",

    "message": "Encountered an unexpected error while evaluating the model. Verify that the serialized input Dataframe is compatible with the model for inference.",

    "stack_trace": "Traceback (most recent call last):\n  File \"/opt/conda/lib/python3.11/site-packages/mlflow/pyfunc/scoring_server/__init__.py\", line 357, in invocations\n    raw_predictions = model.predict(data, params=params)\n                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/mlflow/pyfunc/__init__.py\", line 501, in predict\n    return _predict()\n           ^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/mlflow/pyfunc/__init__.py\", line 487, in _predict\n    return self._predict_fn(data, params=params)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/mlflow/sklearn/__init__.py\", line 517, in predict\n    return self.sklearn_model.predict(data)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/sklearn/ensemble/_forest.py\", line 905, in predict\n    proba = self.predict_proba(X)\n            ^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/sklearn/ensemble/_forest.py\", line 947, in predict_proba\n    X = self._validate_X_predict(X)\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/sklearn/ensemble/_forest.py\", line 636, in _validate_X_predict\n    if self.estimators_[0]._support_missing_values(X):\n       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/opt/conda/lib/python3.11/site-packages/sklearn/tree/_classes.py\", line 188, in _support_missing_values\n    and self.monotonic_cst is None\n        ^^^^^^^^^^^^^^^^^^\nAttributeError: 'DecisionTreeClassifier' object has no attribute 'monotonic_cst'\n"

}

 一开始看到这个报错,我甚至以为我发布错模型了,以至于我这个x_predict的数据不符合他的格式,但是检查之后发现又没有问题。然后有怀疑是python版本问题,然后把训练模型的和部署server的python版本都调整到一模一样,但是依然会报这个错,很奇怪。

后来我把模型发布到本地环境,发现又没有问题了。又返回查看log

2024/02/06 09:21:52 WARNING mlflow.utils.requirements_utils: Detected one or more mismatches between the model's dependencies and the current 
Python environment:
- mlflow (current: 2.10.0, required: mlflow==2.8.1)
- cloudpickle (current: 3.0.0, required: cloudpickle==2.2.1)
- numpy (current: 1.26.3, required: numpy==1.26.2)
- scikit-learn (current: 1.4.0, required: scikit-learn==1.3.2)
- scipy (current: 1.12.0, required: scipy==1.11.4)
To fix the mismatches, call `mlflow.pyfunc.get_model_dependencies(model_uri)` to fetch the model's environment and install dependencies using 
the resulting environment file.

里面有这个warning,抱着试一试的想法,用单独的虚拟环境进行安装他的包,再发布模型

pip install mlflow==2.8.1 cloudpickle==2.2.1 numpy==1.26.2 scikit-learn==1.3.2 scipy==1.11.4

 发布之后也没有告警了,也可以call到了。解决

  • 22
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值