takuya-takeuchi / FaceRecognitionDotNet

The world's simplest facial recognition api for .NET on Windows, MacOS and Linux
MIT License
1.26k stars 308 forks source link

Ubuntu - Illegal instruction (core dumped) #204

Closed carlberg74 closed 2 years ago

carlberg74 commented 2 years ago

Trying to run som FaceEncodings on linux, processing some images. but it crashes on line FaceRecognition.Create below.

My code: Console.WriteLine("- Create Model Parameters!"); var modelParameter = new ModelParameter { PosePredictor68FaceLandmarksModel = File.ReadAllBytes("models/shape_predictor_68_face_landmarks.dat"), PosePredictor5FaceLandmarksModel = File.ReadAllBytes("models/shape_predictor_5_face_landmarks.dat"), FaceRecognitionModel = File.ReadAllBytes("models/dlib_face_recognition_resnet_model_v1.dat"), CnnFaceDetectorModel = File.ReadAllBytes("models/mmod_human_face_detector.dat") };

            Console.WriteLine("- FaceRecognition.Create");
            _fr = FaceRecognition.Create(modelParameter);

Added some gdb dump output:

~/publish$ gdb ./ConsoleApp2 GNU gdb (Ubuntu 9.2-0ubuntu1~20.04.1) 9.2 Copyright (C) 2020 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/. Find the GDB manual and other documentation resources online at: http://www.gnu.org/software/gdb/documentation/.

For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from ./ConsoleApp2... (No debugging symbols found in ./ConsoleApp2) (gdb) run Starting program: /home/user/publish/ConsoleApp2 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". [New Thread 0x7ffff7072700 (LWP 14050)] [New Thread 0x7ffff6871700 (LWP 14051)] [New Thread 0x7ffff6050700 (LWP 14052)] [New Thread 0x7ffff584f700 (LWP 14053)] [New Thread 0x7ffff4a66700 (LWP 14054)] [New Thread 0x7ffff3f28700 (LWP 14055)] [New Thread 0x7ffff1d0a700 (LWP 14056)] [New Thread 0x7ffff1505700 (LWP 14057)] [New Thread 0x7ffff14c0700 (LWP 14058)] Hello Face Recognition! Init

Thread 1 "ConsoleApp2" received signal SIGILL, Illegal instruction. 0x00007fff282e0cbc in get_frontal_face_detector () from /home/user/publish/libDlibDotNetNative.so (gdb)

I have tested: Paths to models; if those are incorrect I get an clear error that models are not found. file access: all models files are directory is accessable.. root: ran as root, same error. .net versions: .net 5 and 6, same error. windows: code works on windows. lib: .so files are exists in directory ~/publish$ ls *.so libDlibDotNetNativeDnnAgeClassification.so
libDlibDotNetNativeDnn.so libDlibDotNetNativeDnnEmotionClassification.so
libDlibDotNetNative.so libDlibDotNetNativeDnnGenderClassification.so

Any sugestions what I can try?

Cheers -Anders

takuya-takeuchi commented 2 years ago

@carlberg74 I've never tried to run on Ubuntu 20.04. So there is any issue about dependencies.

Please tell me more information about environementals.

takuya-takeuchi commented 2 years ago

BTW, did you try https://github.com/takuya-takeuchi/FaceRecognitionDotNet/wiki/Quickstart#ubuntudebian ?

carlberg74 commented 2 years ago

Yes, I have followed the quickguide.

Env: Ubuntu 20.04 Linux snafu 5.4.0-117-generic #132-Ubuntu SMP Thu Jun 2 00:39:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Compiling on Windows with runtime target: linux-x64, target framework .net 5.0 (and 6.0) and copied to linux. What linux envrioment have you tested on?

Tested with python3, just to see if I was missing some dependencies. pip3 install dlib

Script: import dlib detector = dlib.get_frontal_face_detector() facerec = dlib.face_recognition_model_v1("/home/user/publish/models/dlib_face_recognition_resnet_model_v1.dat") img = dlib.load_rgb_image("/home/user/publish/Persons/test.jpg") dets = detector(img, 1) print(dets)

Runs without error and outputs cordinates for a rectagle.

carlberg74 commented 2 years ago

Any idea what else I can try? What linux environment has this been tested on?

takuya-takeuchi commented 2 years ago

Sorry, I am very busy so I have no time to go through issue untill this weekend.

takuya-takeuchi commented 2 years ago

@carlberg74

I created Ubuntu 20.04 Desktop on Hyper-V and try to wrok FRDN program.

1. Install .NET SDK

$ wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
$ sudo dpkg -i packages-microsoft-prod.deb
$ rm packages-microsoft-prod.deb
$ sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-2.1

2. Install git and clone repo

$ sudo aot-get install git
$ git clone https://github.com/takuya-takeuchi/FaceRecognitionDotNet

3. Install dependencies

$ sudo apt-get install libx11-6 libopenblas-dev

4. Try Example

$ cd examples/Benchmark
$ dotnet remove reference ../../src/FaceRecognitionDotNet/FaceRecognitionDotNet.csproj
$ dotnet add package FaceRecognitionDotNet
$ git clone https://github.com/ageitgey/face_recognition_models
$ dotnet run -c Release -- -m=face_recognition_models/face_recognition_models/models
Benchmarks

Timings at 240p:
 - Face locations: 0.0396s (25.25 fps)
 - Face landmarks: 0.0012s (833.33 fps)
 - Encode face (inc. landmarks): 0.0172s (58.14 fps)
 - End-to-end: 0.0570s (17.54 fps)

Timings at 480p:
 - Face locations: 0.1516s (6.60 fps)
 - Face landmarks: 0.0012s (833.33 fps)
 - Encode face (inc. landmarks): 0.0172s (58.14 fps)
 - End-to-end: 0.1688s (5.92 fps)

Timings at 720p:
 - Face locations: 0.3480s (2.87 fps)
 - Face landmarks: 0.0012s (833.33 fps)
 - End-to-end: 0.3674s (2.72 fps)0.0174s (57.47 fps)

Timings at 1080p:
 - Face locations: 0.7806s (1.28 fps)
 - Face landmarks: 0.0012s (833.33 fps)
 - Encode face (inc. landmarks): 0.0174s (57.47 fps)
 - End-to-end: 0.7978s (1.25 fps

It works fine so wiki is not wrong.

takuya-takeuchi commented 2 years ago

@carlberg74 Just in case, could you show your machine cpu? Legacy cpu occur issue.

carlberg74 commented 2 years ago

$ lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 36 bits physical, 48 bits virtual CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 76 Model name: Intel(R) Celeron(R) CPU N3150 @ 1.60GHz Stepping: 3 CPU MHz: 939.320 CPU max MHz: 2080.0000 CPU min MHz: 480.0000 BogoMIPS: 3200.00 Virtualization: VT-x L1d cache: 96 KiB L1i cache: 128 KiB L2 cache: 2 MiB NUMA node0 CPU(s): 0-3 Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Mitigation; Clear CPU buffers; SMT disabled Vulnerability Meltdown: Mitigation; PTI Vulnerability Spec store bypass: Not affected Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP disabled, RSB filling Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes rdrand lahf_lm 3dnowprefetch epb pti ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm ida arat md_clear

takuya-takeuchi commented 2 years ago

@carlberg74 Celeron N3150 does not support AVX. Plesae refer this issue. https://github.com/takuya-takeuchi/DlibDotNet/issues/153#issuecomment-553400395

takuya-takeuchi commented 2 years ago

No response and feedback