已关闭
[Bug-Report|缺陷反馈]: “import torch_npu”会造成MindStudio报错 interrupted by signal 11:SIGSEGV #1442
Bxc.创建于  2025年12月3日关闭于  2025年12月27日
Bxc.
Bxc.
2025年12月3日 创建

Thanks for sending an issue! Please fill in the following template to help quickly solve your problem.

Describe the current behavior / 问题描述 (Mandatory / 必填)

  1. 运行“import torch_npu”会造成MindStudio报错 interrupted by signal 11:SIGSEGV。
  2. 运行官方给出的测试代码运行时间特别长,代码如下:
import torch
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)
  1. 使用 torch_npu.npu.get_device_properties()函数时,运行到`torch_npu.npu._lazy_init()'时会进入死循环

Environment / 环境信息 (Mandatory / 必填)

  • CPU:鲲鹏920 48核*2;
  • GPU:Atlas 300I Duo 96G1 ,Atlas 300I Pro 24G1;
  • CANN Toolkit 版本:8.3.RC1
  • CANN Ketnels 版本:8.3.RC1
  • PyTorch 版本:2.6.0
  • torch-npu 版本:2.6.0.post3

Steps to reproduce the issue / 重现步骤 (Mandatory / 必填)

  1. 关于“运行“import torch_npu”会造成MindStudio报错 interrupted by signal 11:SIGSEGV。”的代码
import torch
import torch_npu
print(torch_npu.__version__)
  1. 关于“运行官方给出的测试代码运行时间特别长”的代码
import torch
x = torch.randn(2, 2).npu()
y = torch.randn(2, 2).npu()
z = x.mm(y)
print(z)
  1. 关于“使用 torch_npu.npu.get_device_properties()函数时,运行到torch_npu.npu._lazy_init()时会进入死循环”的代码
def get_npu_info(index):
	properties = torch_npu.npu.get_device_properties(index)
    return f"{properties.name}, {properties.total_memory / (1 << 20):.0f}MiB"

Describe the expected behavior / 预期结果 (Mandatory / 必填)

  1. 关于“运行“import torch_npu”会造成MindStudio报错 interrupted by signal 11:SIGSEGV。”的期望
    输出2.6.0.post3
  2. 关于“运行官方给出的测试代码运行时间特别长”的期望
    输出z的值,并且运行速度要快
  3. 关于“使用 torch_npu.npu.get_device_properties()函数时,运行到torch_npu.npu._lazy_init()时会进入死循环”的期望
    输出{properties.name}, {properties.total_memory / (1 << 20):.0f}MiB具体信息,同时torch_npu.npu._lazy_init()能顺利通过

关于“运行“import torch_npu”会造成MindStudio报错 interrupted by signal 11:SIGSEGV。”
image.png

Special notes for this issue/备注 (Optional / 选填)

likedislike
huangyunlong成员
2025年12月3日 评论:

1、import torch_npu报错,请查看core堆栈,
这里看到你torch_npu的demo可以运行,说明import torch_npu可以运行,如果发生了core,请采集core堆栈,检查core的原因
2、首次运行存在算子编译等耗时,请观察后续step耗时
或者安装对应kernels包,配置torch.npu.set_compile_mode(jit_compile=False)走二进制,减少编译耗时
更进一步的性能优化,可以采集profiling数据,进行针对性优化
https://www.hiascend.com/document/detail/zh/Pytorch/720/ptmoddevg/trainingmigrguide/performance_tuning_0014.html
3、无法复现,这里是不是底层卡住了,建议在卡住时通过gdb采集堆栈进行定位

likedislike
Bxc.
Bxc.
2025年12月3日 评论:

我根本无法运行import torch_npu,无论我如何重装torch-npu都是这个问题

image.png

likedislike
huangyunlong成员
2025年12月3日 评论:

首先安装配套的驱动,固件,cann,torch,torch_npu,然后如果core了,就查看core堆栈进行定位

likedislike
Bxc.
Bxc.
2025年12月3日 评论:
  1. 已经重装CANN
    image.png
  2. 已经重新创建conda环境
    image.png
  3. 已经创新按照如下创建环境
    image.png
  4. 已经重装Kernel
    image.png
    问题1确实解决,但是问题2,问题3依旧没有达到预期
    image.png
    image.png
likedislike
huangyunlong成员
2025年12月4日 评论:

2,3如果是卡住,需要gdb看下卡住的堆栈,如果是性能差,可以采集profiling看下主要耗时
另外npu首次运行存在初始化等过程,可能耗时长点,可以关注后续step耗时

likedislike
huangyunlong成员
2025年12月4日 评论:

如果感觉卡住了,可以gdb采集堆栈看下卡在哪里

likedislike
Bxc.
Bxc.
2025年12月4日 评论:

我是用gdb采集堆栈,运行samples/inference/ACLHelloWorld官方代码,同样是卡在npu初始阶段
b3c2b077259c23579c9045ae24cb65a3.png

同时我尝试检查我的驱动,使用lspci | grep -i ascendsudo find /usr/local/Ascend -name "ascend310p.ko"都无法显示,我是用./Ascend-hdk-310p-npu-driver_25.2.0_linux-aarch64.run --full --force强制覆盖,依旧出现这类型问题。这是否说明是硬件的问题?

likedislike
huangyunlong成员
2025年12月5日 评论:

目前看到问题出现在底层软件,堆栈显示卡在cann中的setdevice,驱动无法显示,这些都需要咨询下底层cann,驱动,进一步确认问题

likedislike
Hhuangyunlong成员
2025年12月27日 issue状态由 TODO 改变为 DONE
Hhuangyunlong成员
2025年12月27日 关闭了 issue