1.系统环境
硬件环境(Ascend/GPU/CPU): GPU
MindSpore版本: mindspore=2.0
执行模式(PyNative/ Graph):不限
Python版本:3.7
操作系统平台:Linux
2. 问题描述
迁移网络任务-tacotron2时遇到RuntimeError: The pointer[top_cell_] is null.
代码:
boxes = Tensor(boxes,dtype=ms.float32)
lables = Tensor(lables,dtype=ms.int64)
iscrowd = Tensor(iscrowd,dtype=ms.int64)
image_id = Tensor([idx])
area = (boxes[:,3] - boxes[:,1])*(boxes[:,2] - boxes[:,0])
3. 问题分析
MindSpore框架对于单算子的执行只支持单线程操作,但是在自定义数据集__getitem__函数中使用了Tensor的运算操作,即会调到框架的算子执行,由于数据集的处理使用了多线程操作,因此导致整体的执行顺序错乱,出现空指针的错误。因此到看到空指针错误且错误在generator.cc中时,就是在数据集中错误使用了Tensor的运算操作。
4. 解决方案
将Tensor改为numpy操作
boxes = np.array(boxes,dtype=ms.float32)
lables = np.array(lables,dtype=ms.int64)
iscrowd = np.array(iscrowd,dtype=ms.int64)
image_id = np.array([idx])
area = (boxes[:,3] - boxes[:,1])*(boxes[:,2] - boxes[:,0])