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到了。解决

相关推荐

  1. Mlflow部署model serverBAD_REQUEST

    2024-02-09 13:14:01       31 阅读
  2. 前端部署

    2024-02-09 13:14:01       18 阅读
  3. RuoYi微服务部署运行

    2024-02-09 13:14:01       45 阅读

最近更新

  1. 网格化监控:Eureka与分布式服务网格的协同监控

    2024-02-09 13:14:01       0 阅读
  2. Tomcat异步请求实现原理和应用场景简介

    2024-02-09 13:14:01       0 阅读
  3. [Python学习篇] Python面向对象——类

    2024-02-09 13:14:01       1 阅读
  4. 每日一道算法题 LCR 150. 彩灯装饰记录 II

    2024-02-09 13:14:01       1 阅读
  5. Ubuntu 添加so库搜索路径

    2024-02-09 13:14:01       1 阅读
  6. 文件格式是.pb应该怎么查看?

    2024-02-09 13:14:01       1 阅读
  7. 高考假期预习指南

    2024-02-09 13:14:01       1 阅读

热门阅读

  1. k8s学习-Service Account和RBAC授权

    2024-02-09 13:14:01       22 阅读
  2. MySQL优化及索引

    2024-02-09 13:14:01       36 阅读
  3. Ubuntu下的磁盘管理,分区管理,挂载和卸载分区

    2024-02-09 13:14:01       31 阅读
  4. Android中AGP与Gradle、AS、JDK的版本关系

    2024-02-09 13:14:01       35 阅读
  5. re:从0开始的CSS学习之路 7. 盒子模型

    2024-02-09 13:14:01       33 阅读
  6. 寒假作业7

    2024-02-09 13:14:01       31 阅读
  7. Ubuntu 1804 And Above Coredump Settings

    2024-02-09 13:14:01       33 阅读
  8. 【Redis笔记】分布式锁及4种常见实现方法

    2024-02-09 13:14:01       33 阅读
  9. Rust入门2——随机数

    2024-02-09 13:14:01       33 阅读
  10. json模块(高维数据的存储与读取)

    2024-02-09 13:14:01       26 阅读
  11. Rust中的 Cell 和 RefCell

    2024-02-09 13:14:01       30 阅读
  12. 509. 斐波那契数

    2024-02-09 13:14:01       33 阅读