ARM-software / ComputeLibrary

The Compute Library is a set of computer vision and machine learning functions optimised for both Arm CPUs and GPUs using SIMD technologies.
MIT License
2.85k stars 776 forks source link

Error in arm compute while building caffeOnACL #240

Closed anwesha94 closed 7 years ago

anwesha94 commented 7 years ago

Hi, I am trying to build CaffeOnACL on an odroid XU4 board, with ubuntu 16.04 and linux kernel version 4.9.y. However it generates an error:error: invalid conversion from ‘arm_compute::ITensorInfo*’ to ‘unsigned int’ [-fpermissive]

home/odroid/ComputeLibrary/arm_compute/core/Dimensions.h: In instantiation of ‘arm_compute::Dimensions<T>::Dimensions(Ts ...) [with Ts = {arm_compute::TensorInfo*}; T = unsigned int]’: /home/odroid/ComputeLibrary/arm_compute/core/TensorShape.h:47:31: required from ‘arm_compute::TensorShape::TensorShape(Ts ...) [with Ts = {arm_compute::TensorInfo*}]’ src/caffe/acl_layer.cpp:119:5: required from ‘int caffe::BaseTensor<ACLTensor>::tensor_copy(void*, bool) [with ACLTensor = arm_compute::CLTensor]’ src/caffe/acl_layer.cpp:183:6: required from ‘bool caffe::ACLBaseLayer<GPULayer, CPULayer>::tensor_mem(void*, ACLTensor*, bool) [with ACLTensor = caffe::GPUTensor; GPULayer = arm_compute::CLNormalizationLayer; CPULayer = arm_compute::NENormalizationLayer]’ src/caffe/acl_layer.cpp:258:3: required from here /home/odroid/ComputeLibrary/arm_compute/core/Dimensions.h:53:64: error: invalid conversion from ‘arm_compute::TensorInfo*’ to ‘unsigned int’ [-fpermissive] : _id{ { dims... } }, _num_dimensions{ sizeof...(dims) } ^ /home/odroid/ComputeLibrary/arm_compute/core/Dimensions.h: In instantiation of ‘arm_compute::Dimensions<T>::Dimensions(Ts ...) [with Ts = {arm_compute::ITensorInfo*}; T = unsigned int]’: /home/odroid/ComputeLibrary/arm_compute/core/TensorShape.h:47:31: required from ‘arm_compute::TensorShape::TensorShape(Ts ...) [with Ts = {arm_compute::ITensorInfo*}]’ src/caffe/acl_layer.cpp:119:5: required from ‘int caffe::BaseTensor<ACLTensor>::tensor_copy(void*, bool) [with ACLTensor = arm_compute::Tensor]’ src/caffe/acl_layer.cpp:183:6: required from ‘bool caffe::ACLBaseLayer<GPULayer, CPULayer>::tensor_mem(void*, ACLTensor*, bool) [with ACLTensor = caffe::CPUTensor; GPULayer = arm_compute::CLNormalizationLayer; CPULayer = arm_compute::NENormalizationLayer]’ src/caffe/acl_layer.cpp:259:3: required from here /home/odroid/ComputeLibrary/arm_compute/core/Dimensions.h:53:64: error: invalid conversion from ‘arm_compute::ITensorInfo*’ to ‘unsigned int’ [-fpermissive] Makefile:622: recipe for target '.build_release/src/caffe/acl_layer.o' failed make: *** [.build_release/src/caffe/acl_layer.o] Error 1

I tried to suppress the error by adding "-fpermissive" as a CXX_FLAGS in the Makefile of CaffeOnACL. Although it got built, the test run fails giving the following error: PC: @ 0xb61c988a arm_compute::a32_sgemm_8x6() *** SIGSEGV (@0x507000) received by PID 21073 (TID 0x9ed12240) from PID 52715I am using odroid XU4 board with ubuntu 16.04 and linux kernel version 4.9.y.52; stack trace: *** @ 0xb6902270 (unknown) Segmentation fault Can anyone help me with this error? Thank you.

wonjechoi commented 7 years ago

I have same issue. It seems like there is a type conversion problem...

AnthonyBarbier commented 7 years ago

I don't know where the code you're trying to compile lives, but from looking at the code it seems like the problem comes from src/caffe/acl_layer.cpp:258:3: Looks like it's passing a TensorInfo* instead of some dimensions to a constructor or something like that ?

anwesha94 commented 7 years ago

Worked with v17.10 Thank you.

saurabh9911singh commented 7 years ago

Hi @anwesha94 , I was having the same issue with the previous versions. When I used v17.10, this error which you mentioned got removed, but I am getting another error during caffe build ( at 76% )

Error:

CMakeFiles/caffe.dir/common.cpp.o: In function arm_compute::CLScheduler::default_init(arm_compute::ICLTuner*)': common.cpp:(.text._ZN11arm_compute11CLScheduler12default_initEPNS_8ICLTunerE[_ZN11arm_compute11CLScheduler12default_initEPNS_8ICLTunerE]+0x24): undefined reference toarm_compute::CLKernelLibrary::get()' common.cpp:(.text._ZN11arm_compute11CLScheduler12default_initEPNS_8ICLTunerE[_ZN11arm_compute11CLScheduler12default_initEPNS_8ICLTunerE]+0x694): undefined reference to arm_compute::get_target_from_device(cl::Device&)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In functionarm_compute::Iterator::Iterator(arm_compute::ITensor const, arm_compute::Window const&)': acl_layer.cpp:(.text._ZN11arm_compute8IteratorC2EPKNS_7ITensorERKNS_6WindowE[_ZN11arm_compute8IteratorC5EPKNS_7ITensorERKNS_6WindowE]+0x170): undefined reference to `arm_compute::error_on_window_dimensions_gte(char const, char const, int, arm_compute::Window const&, unsigned int)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In function `bool caffe::ACLBaseLayer<arm_compute::CLNormalizationLayer, arm_compute::NENormalizationLayer>::new_tensor(caffe::GPUTensor&, arm_compute::TensorShape, void, bool)': acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute20CLNormalizationLayerENS1_20NENormalizationLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute20CLNormalizationLayerENS1_20NENormalizationLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): undefined reference to arm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In functionbool caffe::ACLBaseLayer<arm_compute::CLNormalizationLayer, arm_compute::NENormalizationLayer>::new_tensor(caffe::CPUTensor&, arm_compute::TensorShape, void, bool)': acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute20CLNormalizationLayerENS1_20NENormalizationLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute20CLNormalizationLayerENS1_20NENormalizationLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): undefined reference to arm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In functionbool caffe::ACLBaseLayer<arm_compute::CLActivationLayer, arm_compute::NEActivationLayer>::new_tensor(caffe::GPUTensor&, arm_compute::TensorShape, void, bool)': acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute17CLActivationLayerENS1_17NEActivationLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute17CLActivationLayerENS1_17NEActivationLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): undefined reference to arm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In functionbool caffe::ACLBaseLayer<arm_compute::CLActivationLayer, arm_compute::NEActivationLayer>::new_tensor(caffe::CPUTensor&, arm_compute::TensorShape, void, bool)': acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute17CLActivationLayerENS1_17NEActivationLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute17CLActivationLayerENS1_17NEActivationLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): undefined reference to arm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In functionbool caffe::ACLBaseLayer<arm_compute::CLPoolingLayer, arm_compute::NEPoolingLayer>::new_tensor(caffe::GPUTensor&, arm_compute::TensorShape, void, bool)': acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute14CLPoolingLayerENS1_14NEPoolingLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute14CLPoolingLayerENS1_14NEPoolingLayerEE10new_tensorINS_9GPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): undefined reference to arm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' CMakeFiles/caffe.dir/acl_layer.cpp.o:acl_layer.cpp:(.text._ZN5caffe12ACLBaseLayerIN11arm_compute14CLPoolingLayerENS1_14NEPoolingLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb[_ZN5caffe12ACLBaseLayerIN11arm_compute14CLPoolingLayerENS1_14NEPoolingLayerEE10new_tensorINS_9CPUTensorEEEbRPT_NS1_11TensorShapeEPvb]+0x70): more undefined references toarm_compute::TensorInfo::TensorInfo(arm_compute::TensorShape const&, arm_compute::Format)' follow CMakeFiles/caffe.dir/acl_layer.cpp.o: In function `void arm_compute::ForEachDimension<6ul>::unroll<caffe::BaseTensor::tensor_copy(void, bool)::{lambda(arm_compute::Coordinates const&)#2}, arm_compute::Iterator&>(arm_compute::Window const&, arm_compute::Coordinates&, caffe::BaseTensor::tensor_copy(void, bool)::{lambda(arm_compute::Coordinates const&)#2}&&, arm_compute::Iterator&)': acl_layer.cpp:(.text._ZN11arm_compute16ForEachDimensionILm6EE6unrollIZN5caffe10BaseTensorINS_8CLTensorEE11tensor_copyEPvbEUlRKNS_11CoordinatesEE0_JRNS_8IteratorEEEEvRKNS_6WindowERS8_OTDpOT0[_ZN11arm_compute16ForEachDimensionILm6EE6unrollIZN5caffe10BaseTensorINS_8CLTensorEE11tensor_copyEPvbEUlRKNS_11CoordinatesEE0_JRNS_8IteratorEEEEvRKNS_6WindowERS8_OTDpOT0]+0x1d0): undefined reference to `arm_compute::error(char const, char const, int, char const, ...)' CMakeFiles/caffe.dir/acl_layer.cpp.o: In function caffe::BaseTensor<arm_compute::CLTensor>::tensor_copy(void*, bool)': acl_layer.cpp:(.text._ZN5caffe10BaseTensorIN11arm_compute8CLTensorEE11tensor_copyEPvb[_ZN5caffe10BaseTensorIN11arm_compute8CLTensorEE11tensor_copyEPvb]+0x350): undefined reference toarm_compute::error(char const, char const, int, char const*, ...)' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTIN11arm_compute10ICPPKernelE[_ZTIN11arm_compute10ICPPKernelE]+0x10): undefined reference to typeinfo for arm_compute::IKernel' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTIN11arm_compute9ICLKernelE[_ZTIN11arm_compute9ICLKernelE]+0x10): undefined reference totypeinfo for arm_compute::IKernel' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN11arm_compute10ICPPKernelE[_ZTVN11arm_compute10ICPPKernelE]+0x20): undefined reference to arm_compute::IKernel::is_parallelisable() const' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN11arm_compute10ICPPKernelE[_ZTVN11arm_compute10ICPPKernelE]+0x28): undefined reference toarm_compute::IKernel::border_size() const' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN11arm_compute9ICLKernelE[_ZTVN11arm_compute9ICLKernelE]+0x20): undefined reference to arm_compute::IKernel::is_parallelisable() const' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN11arm_compute9ICLKernelE[_ZTVN11arm_compute9ICLKernelE]+0x28): undefined reference toarm_compute::IKernel::border_size() const' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN5caffe10BaseTensorIN11arm_compute8CLTensorEEE[_ZTVN5caffe10BaseTensorIN11arm_compute8CLTensorEEE]+0x30): undefined reference to arm_compute::ICLTensor::buffer() const' CMakeFiles/caffe.dir/acl_layer.cpp.o:(.data.rel.ro._ZTVN5caffe9GPUTensorE[_ZTVN5caffe9GPUTensorE]+0x30): undefined reference toarm_compute::ICLTensor::buffer() const' "

I assume it might be some linking error. I'm using CaffeonACL with mview/caffe-android-lib.

Can you help me out?

AnthonyBarbier commented 7 years ago

With the new version of the library you need to link against both arm_compute and arm_compute_core In the previous versions there used to be a bug in our build system and the symbols of core used to be included in the runtime build of the library, this has been fixed and now you need to link against both. So I imagine you need to update your Caffe config to link against both too. (Note: the order matters: you should link against arm_compute first, then against arm_compute_core)

anwesha94 commented 7 years ago

I actually copied the CL_kernels folder that generated inside the build directory to the the build path of compute library and set the LD_LIBRARY_PATH to the build folder. It solved the issue for me. I do not know if this is the exact method to solve the issue, but it works for me.

AnthonyBarbier commented 7 years ago

The best way is to compile with embed_kernels=1, then the OpenCL kernels will be built in the library and you won't need to copy them over to your target.

saurabh9911singh commented 7 years ago

@AnthonyARM yes, I have included arm_compute and arm_compute_core in the make file. So, i don't think its the problem. Also I have built compute library with embed_kernels=1. And @anwesha94 what do you mean by copying cl kernels folder and where to copy? in the android_lib of caffe-android-lib?

saurabh9911singh commented 7 years ago

Hi, can I know which caffe-android lib you are using ? https://github.com/sh1r0/caffe-android-lib or https://github.com/mview/caffe-android-lib

@anwesha94 I'm using https://github.com/mview/caffe-android-lib with ComputeLibrary 17.10 and CaffeOnACL 17.10 and I'm getting this error .

I got stuck here and could not resolve this issue.

Please share how you are running CaffeonACL with ACL?

PS: As you have mentioned its working with v17.10, I'm not raising another new issue. Please don't mind.

anwesha94 commented 7 years ago

Hi @saurabh9911singh, I just followed the installation instructions in https://github.com/OAID/CaffeOnACL

saurabh9911singh commented 7 years ago

Thank you @AnthonyARM and @anwesha94 . It got fixed by linking the arm_compute_core in the build_acl script.

rockrxf commented 7 years ago

I met similar issue while build MXNetOnACL, I tried to use ACL v17.10, but the issue is still there.

/root/mxnet/ComputeLibrary/arm_compute/core/Dimensions.h: In instantiation of ‘arm_compute::Dimensions::Dimensions(Ts ...) [with Ts = {arm_compute::TensorInfo}; T = long unsigned int]’: /root/mxnet/ComputeLibrary/arm_compute/core/TensorShape.h:47:31: required from ‘arm_compute::TensorShape::TensorShape(Ts ...) [with Ts = {arm_compute::TensorInfo}]’ src/operator/acl_bak/acl_layer.cc:121:5: required from ‘int mxnet::op::BaseTensor::tensor_copy(void, bool) [with ACLTensor = arm_compute::CLTensor]’ src/operator/acl_bak/acl_layer.cc:159:6: required from ‘bool mxnet::op::ACLBaseLayer<GPULayer, CPULayer>::tensor_mem(void, ACLTensor, bool) [with ACLTensor = mxnet::op::GPUTensor; GPULayer = arm_compute::CLNormalizationLayer; CPULayer = arm_compute::NENormalizationLayer]’ src/operator/acl_bak/acl_layer.cc:227:3: required from here /root/mxnet/ComputeLibrary/arm_compute/core/Dimensions.h:53:64: error: invalid conversion from ‘arm_compute::TensorInfo’ to ‘long unsigned int’ [-fpermissive] : _id{ { dims... } }, _num_dimensions{ sizeof...(dims) }

AnthonyBarbier commented 7 years ago

@rockrxf : if that's the same issue then this should solve your issue.