PaddlePaddle/PaddleHub

docker 部署 hubserving 启动hub启动报错 ModuleNotFoundError: No module named 'paddle.nn.layer.layers'

szzii opened this issue · 2 comments

szzii commented

docker 部署 hubserving 启动hub启动报错 ModuleNotFoundError: No module named 'paddle.nn.layer.layers'

版本:

  • PaddleHub 2.3.1
  • PaddlePaddle 2.3.2

系统环境:

  • CentOS7
  • docker镜像 registry.baidubce.com/paddlepaddle/paddle:2.3.2
FROM registry.baidubce.com/paddlepaddle/paddle:2.3.2

RUN pip3.7 install --upgrade pip -i https://mirror.baidu.com/pypi/simple

RUN pip3.7 install paddlehub==2.3.1 --upgrade -i https://mirror.baidu.com/pypi/simple

CMD hub

错误信息:

Traceback (most recent call last):
  File "/usr/local/bin/hub", line 5, in <module>
    from paddlehub.commands.utils import execute
  File "/usr/local/lib/python3.7/dist-packages/paddlehub/__init__.py", line 31, in <module>
    from paddlehub import datasets
  File "/usr/local/lib/python3.7/dist-packages/paddlehub/datasets/__init__.py", line 16, in <module>
    from paddlehub.datasets.chnsenticorp import ChnSentiCorp
  File "/usr/local/lib/python3.7/dist-packages/paddlehub/datasets/chnsenticorp.py", line 19, in <module>
    from paddlehub.datasets.base_nlp_dataset import TextClassificationDataset
  File "/usr/local/lib/python3.7/dist-packages/paddlehub/datasets/base_nlp_dataset.py", line 21, in <module>
    import paddlenlp
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/__init__.py", line 35, in <module>
    from . import (
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/data/__init__.py", line 16, in <module>
    from .data_collator import *
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/data/data_collator.py", line 26, in <module>
    from ..transformers import BertTokenizer
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/transformers/__init__.py", line 17, in <module>
    from .model_utils import PretrainedModel, register_base_model
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/transformers/model_utils.py", line 63, in <module>
    from .generation_utils import GenerationMixin
  File "/usr/local/lib/python3.7/dist-packages/paddlenlp/transformers/generation_utils.py", line 29, in <module>
    from paddle.nn.layer.layers import in_declarative_mode
ModuleNotFoundError: No module named 'paddle.nn.layer.layers'

解决方法:

pip3.7 install paddlehub==2.3.1 会安装最新版本 paddlenlp 2.6.0将paddlenlp降级到2.5.2解决

image

起因:

之前构建的镜像突然不能正常运行,可能和更新最新版本有关,不知道我这样构建镜像是否能锁定运行环境版本

SeuHkx commented

我也遇到这样的问题,用的是m2的在docker环境里面跑,降低nlp版本能够解决问题,2.5.0。就是太无语了

是的。paddlehub目前已经不更新了。建议paddle 版本 < 2.4, paddlenlp版本 < 2.6