PaddlePaddle / PaddleHub

Awesome pre-trained models toolkit based on PaddlePaddle. (400+ models including Image, Text, Audio, Video and Cross-Modal with Easy Inference & Serving)【安全加固,暂停交互,请耐心等待】
https://www.paddlepaddle.org.cn/hub
Apache License 2.0
12.74k stars 2.07k forks source link

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

Closed szzii closed 7 months ago

szzii commented 1 year ago

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

版本:

系统环境:

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 1 year ago

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

sijunhe commented 7 months ago

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