基于MindSpore通过GPT实现情感分类报错ModuleNotFoundError: No module named '_pytest'
收藏回复举报
基于MindSpore通过GPT实现情感分类报错ModuleNotFoundError: No module named '_pytest'
t('forum.solved') 已解决
发表于2024-11-07 14:48:16
0 查看

 1 系统环境

大模型平台Jupyter云上开发

硬件环境(Ascend/GPU/CPU): Ascend

MindSpore版本: mindspore=2.3.0

执行模式(PyNative/ Graph):不限

Python版本: Python=3.9

操作系统平台: linux

2 报错信息

2.1 问题描述

执行基于MindSpore通过GPT实现情感分类如下脚本时报错,加载模型失败,无法导入包

cke_3216.png

cke_3864.png

2.2 脚本信息

import os 

 

import mindspore 

from mindspore.dataset import text, GeneratorDataset, transforms 

from mindspore import nn 

 

from mindnlp.dataset import load_dataset 

 

from mindnlp._legacy.engine import Trainer, Evaluator 

from mindnlp._legacy.engine.callbacks import CheckpointCallback, BestModelCallback 

from mindnlp._legacy.metrics import Accuracy 

2.3 报错信息

/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
Building prefix dict from the default dictionary ...
Dumping model to file cache /tmp/jieba.cache
Loading model cost 1.043 seconds.
Prefix dict has been built successfully.
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[3], line 9
      5 from mindspore import nn
      7 from mindnlp.dataset import load_dataset
----> 9 from mindnlp._legacy.engine import Trainer, Evaluator
     10 from mindnlp._legacy.engine.callbacks import CheckpointCallback, BestModelCallback
     11 from mindnlp._legacy.metrics import Accuracy

ModuleNotFoundError: No module named 'mindnlp._legacy'

3 根因分析

******此处由用户填写******

4 解决方案

******此处由用户填写******

包含文字方案和最终脚本代码

请将正确的脚本打包并上传附件

本帖最后由 匿名用户2024/11/07 15:20:20 编辑

我要发帖子