ShiqiYu / libfacedetection

An open source library for face detection in images. The face detection speed can reach 1000FPS.
Other
12.27k stars 3.05k forks source link

CMakeLists.txt doesn't work #91

Closed Grabber closed 5 years ago

Grabber commented 5 years ago
lvmc@X450LD:~/Projects/libfacedetection/build$ make -j4
[ 16%] Building CXX object CMakeFiles/demo.dir/src/facedetectcnn.cpp.o
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp: In function ‘float dotProductFloatChGeneral(float*, float*, int, int)’:
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:115:39: warning: AVX vector return without AVX enabled changes the ABI [-Wpsabi]
     __m256 sumvec = _mm256_setzero_ps();
                                       ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:1227:1: error: inlining failed in call to always_inline ‘__m256 _mm256_setzero_ps()’: target specific option mismatch
 _mm256_setzero_ps (void)
 ^~~~~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:115:38: note: called from here
     __m256 sumvec = _mm256_setzero_ps();
                     ~~~~~~~~~~~~~~~~~^~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:85:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/fmaintrin.h:63:1: error: inlining failed in call to always_inline ‘__m256 _mm256_fmadd_ps(__m256, __m256, __m256)’: target specific option mismatch
 _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
 ^~~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:127:33: note: called from here
         sumvec = _mm256_fmadd_ps(avec, bvec, sumvec);
                  ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:871:1: error: inlining failed in call to always_inline ‘__m256 _mm256_load_ps(const float*)’: target specific option mismatch
 _mm256_load_ps (float const *__P)
 ^~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:120:14: note: called from here
         bvec = _mm256_load_ps(p2 + i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:871:1: error: inlining failed in call to always_inline ‘__m256 _mm256_load_ps(const float*)’: target specific option mismatch
 _mm256_load_ps (float const *__P)
 ^~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:119:14: note: called from here
         avec = _mm256_load_ps(p1 + i);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:269:1: error: inlining failed in call to always_inline ‘__m256 _mm256_hadd_ps(__m256, __m256)’: target specific option mismatch
 _mm256_hadd_ps (__m256 __X, __m256 __Y)
 ^~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:131:28: note: called from here
     sumvec = _mm256_hadd_ps(sumvec, sumvec);
              ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
In file included from /usr/lib/gcc/x86_64-linux-gnu/7/include/immintrin.h:41:0,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.h:54,
                 from /home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:39:
/usr/lib/gcc/x86_64-linux-gnu/7/include/avxintrin.h:269:1: error: inlining failed in call to always_inline ‘__m256 _mm256_hadd_ps(__m256, __m256)’: target specific option mismatch
 _mm256_hadd_ps (__m256 __X, __m256 __Y)
 ^~~~~~~~~~~~~~
/home/lvmc/Projects/libfacedetection/src/facedetectcnn.cpp:132:28: note: called from here
     sumvec = _mm256_hadd_ps(sumvec, sumvec);
              ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~
CMakeFiles/demo.dir/build.make:134: recipe for target 'CMakeFiles/demo.dir/src/facedetectcnn.cpp.o' failed
make[2]: *** [CMakeFiles/demo.dir/src/facedetectcnn.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/demo.dir/all' failed
make[1]: *** [CMakeFiles/demo.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
zhangpiu commented 5 years ago

The same issue!

kaijunzhan commented 5 years ago

same issue here. Ubuntu 18

HongChow commented 5 years ago

@kaijunzhan @Grabber @zhangpiu You can take a look at mine for reference: cmake_minimum_required(VERSION 3.5) project(ShiqiYu_FaceDetect) set(CMAKE_CXX_STANDARD 11) SET( CMAKE_CXX_FLAGS "-std=c++11 -O3 ") add_definitions( -DOPENCV )

set(CMAKE_CXX_FLAGS "-mavx -mfma")

set(OpenCV_DIR $ENV{HOME}/bin/opencv-3.4.0/install/share/OpenCV) find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_INCLUDE_DIRS} )

include_directories(src)

SET(SRC_FILES src/facedetectcnn-model.cpp src/facedetectcnn.cpp src/facedetectcnn-floatdata.cpp) add_library(libface SHARED ${SRC_FILES}) add_executable(libface_example example/libfacedetectcnn-example.cpp) target_link_libraries(libface_example ${OpenCV_LIBS} libface)

############### The key point may be : set(CMAKE_CXX_FLAGS "-mavx -mfma") Hope this will help you.

xinguanxi commented 5 years ago

@HongChow it works

queryor commented 5 years ago

when i follow @HongChow make success, but when i run the demo,it is failed. illegal hardware instruction (core dumped)

zhangpiu commented 5 years ago

@kaijunzhan @Grabber @zhangpiu You can take a look at mine for reference: cmake_minimum_required(VERSION 3.5) project(ShiqiYu_FaceDetect) set(CMAKE_CXX_STANDARD 11) SET( CMAKE_CXX_FLAGS "-std=c++11 -O3 ") add_definitions( -DOPENCV )

set(CMAKE_CXX_FLAGS "-mavx -mfma")

set(OpenCV_DIR $ENV{HOME}/bin/opencv-3.4.0/install/share/OpenCV) find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_INCLUDE_DIRS} )

include_directories(src)

SET(SRC_FILES src/facedetectcnn-model.cpp src/facedetectcnn.cpp src/facedetectcnn-floatdata.cpp) add_library(libface SHARED ${SRC_FILES}) add_executable(libface_example example/libfacedetectcnn-example.cpp) target_link_libraries(libface_example ${OpenCV_LIBS} libface)

############### The key point may be : set(CMAKE_CXX_FLAGS "-mavx -mfma") Hope this will help you.

Thank you! It did work. I successfully build the demo using mkdir build && cd build && cmake -DENABLE_AVX2=ON -DENABLE_INT8=ON -DCMAKE_EXE_LINKER_FLAGS='-static-libstdc++' .. && make

HongChow commented 5 years ago

when i follow @HongChow make success, but when i run the demo,it is failed. illegal hardware instruction (core dumped) I am not sure about your case. One thing is that you should confirm your cpu supports some instruction sets such as avx... So your cpu cannot be too old.

kaijunzhan commented 5 years ago

It works for me except many errors / low accuracy- only one face it will say it has 5 faces. Another issue is the display image is very large

Get Outlook for iOShttps://aka.ms/o0ukef


From: HongChow notifications@github.com Sent: Monday, March 18, 2019 6:50:33 PM To: ShiqiYu/libfacedetection Cc: kaijunzhan; Mention Subject: Re: [ShiqiYu/libfacedetection] CMakeLists.txt doesn't work (#91)

when i follow @HongChowhttps://github.com/HongChow make success, but when i run the demo,it is failed. illegal hardware instruction (core dumped) I am not sure about your case. One thing is that you should confirm your cpu support some instruction sets such as avx... So your cpu cannot be too old.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/ShiqiYu/libfacedetection/issues/91#issuecomment-474166433, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ATrA6iwAg-bEg5qrB9IwkzJuTIey9bsGks5vYEJpgaJpZM4b1pcw.

DESUP2 commented 2 years ago

int8x8x2_t a, b; int16x8_t result_vec; int32x4_t d; a = vld2_s8(p1 + i); b = vld2_s8(p2 + i); vdupq_n_s16 sum += vgetq_lane_s32(d, 3); showing error . erroring out . Should i include all these== arm64intr.h arm_acle.h, arm_cmse.h arm_fp16.h arm_mve.h , arm_neon.h ?