Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

鲲鹏平台,arrch64操作系统,ncnn推理结果不正确 #2961

Closed
wangyangneu opened this issue May 28, 2021 · 6 comments
Closed

鲲鹏平台,arrch64操作系统,ncnn推理结果不正确 #2961

wangyangneu opened this issue May 28, 2021 · 6 comments

Comments

@wangyangneu
Copy link

image
前馈输出与x86的结果对不上,请问有什么解决办法么 @nihui

@nihui
Copy link
Member

nihui commented Jun 4, 2021

ctest 能 100% 跑完嘛?

@wangyangneu
Copy link
Author

ctest 能 100% 跑完嘛?

ctest有三个failed
image

@nihui
Copy link
Member

nihui commented Jun 17, 2021

ctest --output-on-failure 输出下具体错误

@wangyangneu
Copy link
Author

ctest --output-on-failure 输出下具体错误

  Start  5: test_squeezenet

5/66 Test #5: test_squeezenet ..................***Failed 0.19 sec
top 0 index not match expect 532 but got 791
test_squeezenet cpu failed use_packing_layout=0 use_fp16_packed=0 use_fp16_storage=0 use_shader_pack8=0 use_bf16_storage=0 use_image_storage=0
CMake Error at /root/work/code/wangyang/ncnn/cmake/run_test.cmake:4 (message):
Test failed with return value '255'

  Start 14: test_convolution

14/66 Test #14: test_convolution .................***Failed 3.26 sec
value not match at c:0 h:0 w:0 expect 3.338143 but got 5.268054
test_layer_cpu failed
test_layer Convolution failed use_packing_layout=0 use_fp16_packed=0 use_fp16_storage=0 use_fp16_arithmetic=0 use_shader_pack8=0 use_bf16_storage=0 use_image_storage=0
test_convolution failed w=9 h=7 c=16 outch=16 kernel=3 dilation=1 stride=1 pad=1 bias=0 act=5 actparams=[-0.013927,0.071340]
CMake Error at /root/work/code/wangyang/ncnn/cmake/run_test.cmake:4 (message):
Test failed with return value '1'

  Start 31: test_innerproduct

31/66 Test #31: test_innerproduct ................***Failed 0.16 sec
CMake Error at /root/work/code/wangyang/ncnn/cmake/run_test.cmake:4 (message):
Test failed with return value 'Segmentation fault'

@tpoisonooo
Copy link
Contributor

tpoisonooo commented Jul 15, 2021

复现了。有一点历史渊源...华为 arm 那套服务器,默认用自己的欧拉。
机器上默认的 g++ 编译器应该是这个:

$ /usr/bin/c++ --version
c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc. 

这个编译器里除了__aarch64__以外,没有__ARM_NEON及其他可能的所有 neon 条件编译。也就是说下面的代码会很奇怪地正常编译过:

#if defined(__ARM_NEON__)
#error "__ARM_NEON__"
#elif defined(_M_ARM)
#error "_M_ARM"
#elif defined(_M_ARM64)
#error "_M_ARM64"
#elif defined(_M_HYBRID_X86_ARM64)
#error "hybrid"
#elif defined(__aarch64__)
// #error "__aarch64__"
#endif

这会导致一些 __ARM_NEON 包的代码没有执行,例如这句

#if __ARM_NEON
    if (opt.use_packing_layout || opt.use_int8_inference)
    {
        flatten = ncnn::create_layer(ncnn::LayerType::Flatten);

        ncnn::ParamDict pd;

        flatten->load_param(pd);

        flatten->create_pipeline(opt);
    }
#endif // __ARM_NEON

flatten handle 是 0x0,触发后面的 crash。因此最简单的修复方法是:

安装 g++-7

以 centos 为例(我印象里华为 stable 的 OS 只有两个版本,也没啥好选的)

$ yum install -y centos-release-scl
$ yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++
$ source /opt/rh/devtoolset-7/enable 

改掉默认的 CMAKE_CXX_COMPILER

在 toolchain 里面抄一个新的 host-c.gcc.toolchain.cmake,内容就三行

$ cat ../toolchains/host-c.gcc.toolchain.cmake 
SET ( CMAKE_C_COMPILER "gcc" )
SET ( CMAKE_CXX_COMPILER "g++" )
SET ( CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}" )

创建个新的 build 目录,编译运行

$ mkdir build && build && cmake3 -DCMAKE_TOOLCHAIN_FILE=../toolchains/host-c.gcc.toolchain.cmake  ..
$ make -j
$ ./tests/test_innerproduct

我这边就正常了。我是幸福,祝福你狗子...

nihui added a commit to nihui/ncnn that referenced this issue Jul 20, 2021
@nihui nihui closed this as completed in 2c4ae09 Jul 20, 2021
@nihui
Copy link
Member

nihui commented Jul 20, 2021

应该修好啦,有问题可以 reopen issue

leiyu2 added a commit to leiyu2/ncnn that referenced this issue Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants