1 系统环境
硬件环境(Ascend/GPU/CPU): Ascend
MindSpore版本: 2.2
执行模式(PyNative/ Graph): 不限
2 报错信息
2.1 问题描述
之前能够跑通的wizardcoder训练代码,在引入mindspore.ops.Print()后再次运行无法跑通。
2.2 报错信息
uring handling of the above exception, another exception occurred:
File "/home/liyejun/miniconda3/envs /test0823/lib/python3.7/multiproc essing/connection.py", line 368, in _send
n = write(seif. handle. buf)
rokenPipeError: [Errno 32] Broken pipe
raceback (most recet catl last)
rokenPipeError: [Errno 32] Broken pipe
3 根因分析
使用日志打印功能来查看。命令如下:
export GLOG_v = 1: mindspore日志输出等级设置,设为2后停止输出
export ASCEND_GLOBAL_LOG_LEVEL=1: CANN相关日志等级
export ASCEND_SLOG_PRINT_TO_STDOUT=1: CANN相关日志控制,0不输出,1打屏
找到出错的位置,查看前后信息,有一行信息是“type of scalar to print is not support”,推测是在调试的过程中使用了mindspore的mindspore.ops.Print(),打印的对象不满足要求,导致报错。
4 解决方案
在wizardcoder.py文件中添加了上述print功能,将其注释或者删除后可以跑通,具体位置在WizardCoderLMHeadModel类的__init__()和construct()中。
self.tile = P.Tile()
self.concat = P.Concat(axis=-1)
# self.print - = mindspore.ops.Print()
def _add_eos_to_inputs(self, target_ids):...
output_states, table = self.backbone(tokens, attention_mask)
# self.print('------------------------')
# self.print(output_states. shape)
# self.print(table.shape)
logits = self.head(output_states table)
分析官网对于 ops.Print() 的介绍 ( 参 见 : https://www.mindspore.cn/docs/zh-
CN/r2.1/api_python/ops/mindspore.ops.Print.html#mindspore.ops.Print)
官网说明ops.Print()的入参可以是str、Tensor、int等的union组合, 只注释如下行代码,发现能够正确跑通代码且打印出对应的shape值。
# self.print('------------------------')
self.print(output_states. shape)
self.print(table.shape)
logits = self.head(output_states table