windows10环境 Python3.8 运行下面代码: from modelscope.pipelines import pipeline from modelscope.utils.constant import Tasks text_generation_zh = pipeline(Tasks.text_generation, model='damo/nlp_gpt3_poetry-generation_chinese-large') result_zh = text_generation_zh("金榜题名") print(result_zh['text']) 报错如下: 2023-06-08 13:36:34,700 - modelscope - INFO - PyTorch version 2.0.1 Found. 2023-06-08 13:36:34,713 - modelscope - INFO - TensorFlow version 2.11.0 Found. 2023-06-08 13:36:34,713 - modelscope - INFO - Loading ast index from C:\Users\Administrator.cache\modelscope\ast_indexer 2023-06-08 13:36:34,831 - modelscope - INFO - Loading done! Current index file version is 1.4.1, with md5 cffc52c9e200c4449701dcba46014061 and a total number of 842 components indexed 2023-06-08 13:36:51,443 - modelscope - INFO - Model revision not specified, use the latest revision: v1.0.1 2023-06-08 13:36:51,773 - modelscope - INFO - initiate model from C:\Users\Administrator.cache\modelscope\hub\damo\nlp_gpt3_poetry-generation_chinese-large 2023-06-08 13:36:51,773 - modelscope - INFO - initiate model from location C:\Users\Administrator.cache\modelscope\hub\damo\nlp_gpt3_poetry-generation_chinese-large. 2023-06-08 13:36:51,778 - modelscope - INFO - initialize model from C:\Users\Administrator.cache\modelscope\hub\damo\nlp_gpt3_poetry-generation_chinese-large Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\import_utils.py", line 433, in get_module return importlib.import_module('.' + module_name, self.name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\importlib_init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in load_unlocked File "", line 783, in exec_module File "", line 219, in call_with_frames_removed File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\models\nlp\gpt3\backbone.py", line 29, in from .distributed_gpt3 import sample File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\models\nlp\gpt3\distributed_gpt3.py", line 22, in from megatron_util import get_args, mpu File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\megatron_util_init.py", line 19, in from .initialize import initialize_megatron File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\megatron_util\initialize.py", line 29, in from megatron_util import mpu File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\megatron_util\mpu_init.py", line 87, in from .grads import clip_grad_norm File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\megatron_util\mpu\grads.py", line 19, in from torch._six import inf ModuleNotFoundError: No module named 'torch._six'
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\registry.py", line 212, in build_from_cfg return obj_cls(**args) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\pipelines\nlp\text_generation_pipeline.py", line 56, in init super().init( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\pipelines\base.py", line 94, in init self.model = self.initiate_single_model(model) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\pipelines\base.py", line 53, in initiate_single_model return Model.from_pretrained( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\models\base\base_model.py", line 144, in from_pretrained model = build_model(model_cfg, task_name=task_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\models\builder.py", line 35, in build_model model = build_from_cfg( File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\registry.py", line 184, in build_from_cfg LazyImportModule.import_module(sig) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\import_utils.py", line 457, in import_module importlib.import_module(module_name) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\importlib_init_.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 975, in _find_and_load_unlocked File "", line 671, in _load_unlocked File "", line 783, in exec_module File "", line 219, in _call_with_frames_removed File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\models\nlp\gpt3\text_generation.py", line 11, in from modelscope.models.nlp.gpt3 import GPT3Model File "", line 1039, in _handle_fromlist File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\import_utils.py", line 416, in getattr module = self._get_module(self._class_to_module[name]) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\import_utils.py", line 435, in _get_module raise RuntimeError( RuntimeError: Failed to import modelscope.models.nlp.gpt3.backbone because of the following error (look up to see its traceback): No module named 'torch._six'
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\modelscope\utils\registry.py", line 215, in build_from_cfg raise type(e)(f'{obj_cls.name}: {e}') RuntimeError: TextGenerationPipeline: Failed to import modelscope.models.nlp.gpt3.backbone because of the following error (look up to see its traceback): No module named 'torch._six' python-BaseException
确保您已经安装了 PyTorch,并且版本正确。您可以使用以下命令在 Python 中检查 PyTorch 的版本:
Copy
import torch
print(torch.version)
```
如果 PyTorch 的版本不正确,可以尝试更新或降级 PyTorch。
确保您已经安装了 ModelScope 并且版本正确。您可以使用以下命令在 Python 中检查 ModelScope 的版本:
Copy
import modelscope
print(modelscope.version)
如果 ModelScope 的版本不正确,可以尝试更新或降级 ModelScope。
确保您已经安装了所有必要的依赖项。您可以查看官方文档,以获取有关所需依赖项的信息。如果您使用的是 Anaconda 或 pip 等包管理器,则可以使用以下命令安装必要的依赖项:
basic
Copy
pip install -r requirements.txt
如果问题仍然存在,请尝试在另一个环境中运行示例代码,以确定问题是否与特定环境相关。您可以创建一个虚拟环境并在其中安装必要的依赖项和软件包。
在GPT-3诗词生成模型-中文-large这个模型的notebook快速开发环境中选择cpu配置的跑不出来效果,也没报错,就是等待。但是在gpu的环境中可以出来结果。模型的说明wendn文档里也没有说明不能在cpu上运行或者需要依赖gpu环境
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352