ARM64架构上编译numpy报错解决

在 ARMv8架构上编译 numpy

对较早版本的numpy,如果直接执行 python3 setup.py install,就会报告错误:

In file included from numpy/core/include/numpy/npy_math.h:580:0,
                 from numpy/core/src/npymath/npy_math_common.h:9,
                 from numpy/core/src/npymath/npy_math_complex.c.src:34:
numpy/core/src/npymath/npy_math_internal.h.src: In function ‘npy_cacoshf’:
numpy/core/src/npymath/npy_math_internal.h.src:482:12: internal compiler error: Segmentation fault
     return @kind@@c@(x, y);
            ^~~~~~~~~~~~~~~
0x994aff crash_signal

参考 Github 上的 Issue,需要如下下的补丁文件:

diff --git a/numpy/core/src/npymath/npy_math_internal.c.src b/numpy/core/src/npymath/npy_math_internal.c.src
index dad3812..adcd83c 100644
--- numpy/core/src/npymath/npy_math_internal.h.src 2019-11-14 04:20.387180922 +0000
+++ numpy/core/src/npymath/npy_math_internal.h.src 2019-11-14 04:20.960646234 +0000
@@ -477,7 +477,7 @@
 * #KIND = ATAN2,HYPOT,POW,FMOD,COPYSIGN#
 */
 #ifdef HAVE_@KIND@@C@
-NPY_INPLACE @type@ npy_@kind@@c@(@type@ x, @type@ y)
+NPY_INPLACE __attribute__((optimize("-O0"))) @type@ npy_@kind@@c@(@type@ x, @type@ y)
 {
 return @kind@@c@(x, y);
 }

将这个补丁打到 numpy/core/src/npymath/npy_math_internal.c.src 上,即可解决问题。
这个问题可以在华为社区多次搜索到。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值