求助: 运行模型时报错module 'megatron_util.mpu' has no attribute 'get_model_parallel_rank'

本文涉及的产品
NLP自然语言处理_高级版,每接口累计50万次
NLP 自学习平台,3个模型定制额度 1个月
NLP自然语言处理_基础版,每接口每天50万次
简介: 运行ZhipuAI/Multilingual-GLM-Summarization-zh的官方代码范例时,报错AttributeError: MGLMTextSummarizationPipeline: module 'megatron_util.mpu' has no attribute 'get_model_parallel_rank'环境是基于ModelScope官方docker镜像,尝试了各个版本结果都是一样的。

运行ZhipuAI/Multilingual-GLM-Summarization-zh的官方代码范例时,报错AttributeError: MGLMTextSummarizationPipeline: module 'megatron_util.mpu' has no attribute 'get_model_parallel_rank'
环境是基于ModelScope官方docker镜像,尝试了各个版本结果都是一样的。也尝试使用
pip uninstall megatron_util && pip install megatron_util -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html重新安装各个版本的megatron_util,但是还是没有效果。
具体报错内容如下:

root@dc19cfd686f9:/app# python test.py 
2023-11-19 03:45:04,162 - modelscope - INFO - PyTorch version 1.11.0+cu113 Found.
2023-11-19 03:45:04,163 - modelscope - INFO - Loading ast index from /mnt/workspace/.cache/modelscope/ast_indexer
2023-11-19 03:45:04,181 - modelscope - INFO - Loading done! Current index file version is 1.6.1, with md5 7ef0ea14f2ab92de0a689c4b4f9dd76d and a total number of 849 components indexed
2023-11-19 03:45:05,183 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.1
No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
[2023-11-19 03:45:06,171] [INFO] [real_accelerator.py:158:get_accelerator] Setting ds_accelerator to cuda (auto detect)
WARNING: No training data specified
using world size: 1 and model-parallel size: 1 
 > using dynamic loss scaling
megatron initialized twice
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /opt/conda/lib/python3.7/site-packages/modelscope/utils/registry.py:212 in build_from_cfg        │
│                                                                                                  │
│   209 │   │   if hasattr(obj_cls, '_instantiate'):                                               │
│   210 │   │   │   return obj_cls._instantiate(**args)                                            │
│   211 │   │   else:                                                                              │
│ ❱ 212 │   │   │   return obj_cls(**args)                                                         │
│   213 │   except Exception as e:                                                                 │
│   214 │   │   # Normal TypeError does not print class name.                                      │
│   215 │   │   raise type(e)(f'{obj_cls.__name__}: {e}')                                          │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/nlp/mglm_text_summarization_pipeline │
│ .py:29 in __init__                                                                               │
│                                                                                                  │
│   26 │   │   │   │    *args,                                                                     │
│   27 │   │   │   │    **kwargs):                                                                 │
│   28 │   │   model = MGLMForTextSummarization(model) if isinstance(model,                        │
│ ❱ 29 │   │   │   │   │   │   │   │   │   │   │   │   │   │   │     str) else model               │
│   30 │   │   self.model = model                                                                  │
│   31 │   │   self.model.eval()                                                                   │
│   32 │   │   if preprocessor is None:                                                            │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/models/nlp/mglm/mglm_for_text_summarization.py │
│ :371 in __init__                                                                                 │
│                                                                                                  │
│   368 │   │   # setting default batch size to 1                                                  │
│   369 │   │   self.args.batch_size = 1                                                           │
│   370 │   │   self.args.tokenizer_path = model_dir                                               │
│ ❱ 371 │   │   self.tokenizer = prepare_tokenizer(self.args)                                      │
│   372 │   │   self.model = setup_model(self.args)                                                │
│   373 │   │   self.cfg = Config.from_file(                                                       │
│   374 │   │   │   osp.join(model_dir, ModelFile.CONFIGURATION))                                  │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/models/nlp/mglm/configure_data.py:147 in       │
│ prepare_tokenizer                                                                                │
│                                                                                                  │
│   144 │   │   add_task_mask=args.task_mask,                                                      │
│   145 │   │   add_decoder_mask=args.block_mask_prob > 0.0                                        │
│   146 │   │   or args.context_mask_ratio > 0.0)                                                  │
│ ❱ 147 │   if mpu.get_model_parallel_rank() == 0:                                                 │
│   148 │   │   num_tokens = tokenizer.num_tokens                                                  │
│   149 │   │   eod_token = tokenizer.get_command('eos').Id                                        │
│   150 │   │   assert eod_token == tokenizer.get_command('pad').Id                                │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'megatron_util.mpu' has no attribute 'get_model_parallel_rank'

During handling of the above exception, another exception occurred:

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /app/test.py:11 in <module>                                                                      │
│                                                                                                  │
│    8 pipe = pipeline(                                                                            │
│    9 │   task=Tasks.text_summarization,                                                          │
│   10 │   model=model,                                                                            │
│ ❱ 11 │   preprocessor=preprocessor,                                                              │
│   12 )                                                                                           │
│   13 result = pipe(                                                                              │
│   14 │   '据中国载人航天工程办公室消息,北京时间2022年10月25日,梦天实验舱与长征五号B遥四运载    │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py:140 in pipeline           │
│                                                                                                  │
│   137 │   if preprocessor is not None:                                                           │
│   138 │   │   cfg.preprocessor = preprocessor                                                    │
│   139 │                                                                                          │
│ ❱ 140 │   return build_pipeline(cfg, task_name=task)                                             │
│   141                                                                                            │
│   142                                                                                            │
│   143 def add_default_pipeline_info(task: str,                                                   │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py:57 in build_pipeline      │
│                                                                                                  │
│    54 │   │   default_args (dict, optional): Default initialization arguments.                   │
│    55 │   """                                                                                    │
│    56 │   return build_from_cfg(                                                                 │
│ ❱  57 │   │   cfg, PIPELINES, group_key=task_name, default_args=default_args)                    │
│    58                                                                                            │
│    59                                                                                            │
│    60 def pipeline(task: str = None,                                                             │
│                                                                                                  │
│ /opt/conda/lib/python3.7/site-packages/modelscope/utils/registry.py:215 in build_from_cfg        │
│                                                                                                  │
│   212 │   │   │   return obj_cls(**args)                                                         │
│   213 │   except Exception as e:                                                                 │
│   214 │   │   # Normal TypeError does not print class name.                                      │
│ ❱ 215 │   │   raise type(e)(f'{obj_cls.__name__}: {e}')                                          │
│   216                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: MGLMTextSummarizationPipeline: module 'megatron_util.mpu' has no attribute 'get_model_parallel_rank'

代码内容如下:

from modelscope.models import Model
from modelscope.pipelines import pipeline
from modelscope.preprocessors import MGLMSummarizationPreprocessor
from modelscope.utils.constant import Tasks

model = 'ZhipuAI/Multilingual-GLM-Summarization-zh'
preprocessor = MGLMSummarizationPreprocessor()
pipe = pipeline(
    task=Tasks.text_summarization,
    model=model,
    preprocessor=preprocessor,
    model_revision='v1.0.1',
)
result = pipe(
    '据中国载人航天工程办公室消息,北京时间2022年10月25日,梦天实验舱与长征五号B遥四运载火箭组合体已转运至发射区。后续将按计划开展发射前各项功能检查和联合测试等工作,计划于近日择机实施发射。目前,文昌航天发射场设施设备状态良好,参试各单位正在加紧开展任务准备,全力以赴确保空间站建造任务决战决胜。'
)  
print(result)
目录
相关文章
|
4月前
|
TensorFlow API 算法框架/工具
【Tensorflow+keras】解决使用model.load_weights时报错 ‘str‘ object has no attribute ‘decode‘
python 3.6,Tensorflow 2.0,在使用Tensorflow 的keras API,加载权重模型时,报错’str’ object has no attribute ‘decode’
62 0
问题出在`megatron_util.mpu`模块中没有找到`get_model_parallel_rank`属性
问题出在`megatron_util.mpu`模块中没有找到`get_model_parallel_rank`属性
123 1
|
7月前
|
机器学习/深度学习 人工智能
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
【CatBoost报错解决】CatBoostError: Bad value for num feature[non default doc idx=0,feature idx=19]=
|
API 数据格式
TensorFlow2._:model.summary() Output Shape为multiple解决方法
TensorFlow2._:model.summary() Output Shape为multiple解决方法
289 0
TensorFlow2._:model.summary() Output Shape为multiple解决方法
Re1:读论文 C&S (Correct and Smooth) Combining Label Propagation and Simple Models Out-performs Graph Ne
Re1:读论文 C&S (Correct and Smooth) Combining Label Propagation and Simple Models Out-performs Graph Ne
Re1:读论文 C&S (Correct and Smooth) Combining Label Propagation and Simple Models Out-performs Graph Ne
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
onnx-tensorrt:builtin_op_importers.cpp:628:5: error: ‘IIdentityLayer’ is not a member of ‘nvinfer1’
108 0
|
算法框架/工具 Windows
|
SQL XML 缓存
《Orca: A Modular Query Optimizer Architecture for Big Data》
Orca: A Modular Query Optimizer Architecture for Big Data
《Orca: A Modular Query Optimizer Architecture for Big Data》
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
成功解决h5py\_init_.py:26:FutureWarning: Conversion of the second argument of issubdtype from `float` to
|
XML 分布式计算 算法
Orca: A Modular Query Optimizer Architecture for Big Data
在之前的几片paper笔记中,对最为主流的两套优化器框架进行了解读,包括bottom-up dynamic programming的search策略和基于Top-down memorization的search策略
399 0
Orca: A Modular Query Optimizer Architecture for Big Data

热门文章

最新文章