335 Star 1.5K Fork 858

MindSpore / docs

 / 详情

文档反馈-教程

VALIDATION
Documentation
创建于  
2024-03-27 20:26
  1. 【Document Link】/【文档链接】

https://www.mindspore.cn/tutorials/experts/zh-CN/r2.2/operation/op_custom.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%AE%97%E5%AD%90%E5%85%A5%E9%97%A8-%E4%B8%80%E4%B8%AA%E4%BE%8B%E5%AD%90

  1. 【Issues Section】/【问题文档片段】
 import numpy as np
 from mindspore import ops
 import mindspore as ms
 from mindspore.ops import kernel

 # 算子实现,Hybrid DSL
 @kernel
 def add(a, b):
     c = output_tensor(a.shape, a.dtype)
     for i0 in range(a.shape[0]):
         for i1 in range(a.shape[1]):
             c[i0, i1] = a[i0, i1] + b[i0, i1]
     return c
 if __name__ == "__main__":
     # 定义hybrid类型的自定义算子(Custom的默认模式)
     op = ops.Custom(add)
     x0 = np.array([[0.0, 0.0], [1.0, 1.0]]).astype(np.float32)
     x1 = np.array([[2.0, 2.0], [3.0, 3.0]]).astype(np.float32)
     output = op(ms.Tensor(x0), ms.Tensor(x1))
     print(output)
  1. 【Issues Section】/【问题文档片段】

npu下单独运行产生多个报错BrokenPipeError: [Errno 32] Broken pipe

  1. 【Expected Result】【预期结果】
  • Please fill in the expected result> 这里输入引用文本

评论 (5)

tn 创建了Documentation

Please assign maintainer to check this issue.
请为此issue分配处理人。
@fangwenyi @chengxiaoli @Shawny

感谢您的提问,您可以评论//mindspore-assistant更快获取帮助:

  1. 如果您刚刚接触MindSpore,或许您可以在教程找到答案
  2. 如果您是资深Pytorch用户,您或许需要:
  1. 如果您遇到动态图问题,可以设置set_context(pynative_synchronize=True)查看报错栈协助定位
  2. 模型精度调优问题可参考官网调优指南
  3. 如果您反馈的是框架BUG,请确认您在ISSUE中提供了MindSpore版本、使用的后端类型(CPU、GPU、Ascend)、环境、训练的代码官方链接以及可以复现报错的代码的启动方式等必要的定位信息
  4. 如果您已经定位出问题根因,欢迎提交PR参与MindSpore开源社区,我们会尽快review

你好,我看这边装饰器用的是@sample,这里应该用@kernel,如果还是有问题,麻烦贴出完整的报错信息和代码,谢谢

import numpy as np
from mindspore import ops
import mindspore as ms
from mindspore.ops import kernel




# 算子实现,Hybrid DSL
@kernel
def add(a, b):
    c = output_tensor(a.shape, a.dtype)
    for i0 in range(a.shape[0]):
        for i1 in range(a.shape[1]):
            c[i0, i1] = a[i0, i1] + b[i0, i1]
    return c


if __name__ == "__main__":
    # 定义hybrid类型的自定义算子(Custom的默认模式)
    op = ops.Custom(add)
    x0 = np.array([[0.0, 0.0], [1.0, 1.0]]).astype(np.float32)
    x1 = np.array([[2.0, 2.0], [3.0, 3.0]]).astype(np.float32)
    output = op(ms.Tensor(x0), ms.Tensor(x1))
    print(output)

报错信息

(venv) [服务器]$ python test_hybrid.py
[WARNING] ME(93027:281473670082800,MainProcess):2024-03-29-06:35:15.717.13 [mindspore/run_check/_check_version.py:348] Using custom Ascend AI software package (Ascend Data Center Solution) path, package version checking is skipped. Please make sure Ascend AI software package (Ascend Data Center Solution) version is supported. For details, refer to the installation guidelines https://www.mindspore.cn/install
[WARNING] ME(93027:281473670082800,MainProcess):2024-03-29-06:35:15.719.59 [mindspore/run_check/_check_version.py:468] Can not find driver so(need by mindspore-ascend). Please check whether the Environment Variable LD_LIBRARY_PATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install
[WARNING] ME(93027:281473670082800,MainProcess):2024-03-29-06:35:18.761.194 [mindspore/ops/operations/custom_ops.py:544] For 'Custom', 'func_type': hybrid, 'func': <function add at 0xffff0a1d8e50>, 'out_shape' or 'out_dtype' is None, infer the output shape and output dtype automatically. There might be some Python RuntimeWarning but it wouldn't influence the result.
[WARNING] GE_ADPT(93027,ffffb21e70f0,python):2024-03-29-06:35:33.367.784 [mindspore/ccsrc/transform/graph_ir/utils.cc:77] FindAdapter] Can't find OpAdapter for Custom_add_8cd0dbca4c3a95114ad742596ec86291719a964dd46d8a85ac40000e1173937a
Segmentation fault
(venv) [服务器]$ Process ForkServerPoolWorker-4:
Process ForkServerPoolWorker-7:
Process ForkServerPoolWorker-3:
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
Traceback (most recent call last):
Process ForkServerPoolWorker-6:
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
Process ForkServerPoolWorker-8:
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe
Process ForkServerPoolWorker-2:
Process ForkServerPoolWorker-9:
Process ForkServerPoolWorker-5:
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
BrokenPipeError: [Errno 32] Broken pipe
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)

During handling of the above exception, another exception occurred:

  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 131, in worker
    put((job, i, result))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

BrokenPipeError: [Errno 32] Broken pipe
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))

During handling of the above exception, another exception occurred:


During handling of the above exception, another exception occurred:

Traceback (most recent call last):

During handling of the above exception, another exception occurred:

  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
Traceback (most recent call last):
Traceback (most recent call last):
Traceback (most recent call last):
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
BrokenPipeError: [Errno 32] Broken pipe
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/pool.py", line 136, in worker
    put((job, i, (False, wrapped)))
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/queues.py", line 368, in put
    self._writer.send_bytes(obj)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
  File "/home/Python-3.8.18/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe
BrokenPipeError: [Errno 32] Broken pipe
/home/Python-3.8.18/lib/python3.8/multiprocessing/resource_tracker.py:216: UserWarning: resource_tracker: There appear to be 97 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

Shawny 负责人设置为zichun_ye
Shawny 关联项目设置为MindSpore Issue Assistant
Shawny 计划开始日期设置为2024-03-29
Shawny 计划截止日期设置为2024-04-29
Shawny 添加了
 
mindspore-assistant
标签
Shawny 添加了
 
sig/ops
标签
Shawny 任务状态TODO 修改为VALIDATION
tn 修改了描述
tn 修改了描述
tn 修改了描述
tn 修改了描述
i-robot 添加了
 
www
标签
i-robot 添加了
 
www
标签

您好,由于问题单没有回复,我们后续会关闭,如您仍有疑问,可以反馈下具体信息,并将ISSUE状态修改为WIP,我们这边会进一步跟踪,谢谢

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(3)
6571795 zichun ye 1595984050
1
https://gitee.com/mindspore/docs.git
git@gitee.com:mindspore/docs.git
mindspore
docs
docs

搜索帮助