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

ImportError: Could not load libInspireFace.so. #62

Closed
0714lxy0714 opened this issue Jun 2, 2024 · 4 comments
Closed

ImportError: Could not load libInspireFace.so. #62

0714lxy0714 opened this issue Jun 2, 2024 · 4 comments

Comments

@0714lxy0714
Copy link

Hello, I would like to ask about an environment configuration issue. While testing on Ubuntu and following the given environment configuration requirements, I configured the environment twice. During the debugging process, the same error occurred. What could be the problem?
(InspireFace) l@l-ThinkStation-P920:/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python$ python
Python 3.8.19 (default, Mar 20 2024, 19:58:24)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

import os
import cv2
import inspireface as ifac
Traceback (most recent call last):
File "", line 1, in
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/init.py", line 1, in
from .modules import *
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/modules/init.py", line 1, in
from .inspire_face import ImageStream, FaceExtended, FaceInformation, SessionCustomParameter, InspireFaceSession,
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/modules/inspire_face.py", line 3, in
from .core import *
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/modules/core/init.py", line 1, in
from .native import *
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/modules/core/native.py", line 870, in
_libs[_LIBRARY_FILENAME] = load_library(_LIBRARY_FILENAME)
File "/media/l/56c1a6af-6c26-4b19-8667-59642efbd717/InspireFace/python/inspireface/modules/core/native.py", line 558, in call
raise ImportError("Could not load %s." % libname)
ImportError: Could not load libInspireFace.so.

@0714lxy0714
Copy link
Author

mmexport1717334303736

@tunmx
Copy link
Member

tunmx commented Jul 5, 2024

Hello, the reasons for the .so file failing to load successfully are:

  1. You must copy or create a symlink for the compiled insightface.so file and place it in the python/inspireface/modules/core/ directory to ensure that the code can access it..
  2. If you are using an Anaconda virtual environment, there might be a conflict between the version of libstdc++ that the environment relies on and the version required by inspireface.so. Usually, upgrading or replacing the version of libstdc++ can resolve this issue.
  3. Your computer might be missing some libraries that OpenCV depends on.

In the new version(deepinsight/insightface#2607), we have added error messages for when the inspireface.so library fails to load. You can find these messages in the console and follow the prompts to resolve the issues, for example:

python sample_face_detection.py ../test_res/pack/Pikachu ../test_res/data/bulk/face_sample.png
/home/tunm/work/InspireFace/python/inspireface/modules/core/liblibInspireFace.so.so: cannot open shared object file: No such file or directory
/home/tunm/work/InspireFace/python/inspireface/modules/core/libInspireFace.so.so: cannot open shared object file: No such file or directory
/lib/x86_64-linux-gnu/libgtk-3.so.0: undefined symbol: g_mount_operation_set_is_tcrypt_hidden_volume
.....

Additionally, we used GitHub Actions in the development repository to deploy and test Python calls to native code, and it ran successfully. You can refer to the script for details: CI Script

@github-rajs
Copy link

buid is successful but unable to load module file, please suggest.

(base) raj@ryzenbeast:/datadisk/inspireface$ bash ci/quick_test_linux_x86_usual_python_native_interface.sh
Directory 'test_res' already exists. Skipping download.
Default or fallback case for MNN setup
CMake Deprecation Warning at 3rdparty/MNN/CMakeLists.txt:1 (cmake_minimum_required):
Compatibility with CMake < 3.5 will be removed from a future version of
CMake.

Update the VERSION argument value or use a ... suffix to tell
CMake that the project does not need compatibility with older versions.

-- Use Threadpool, forbid openmp
-- >>>>>>>>>>>>>
-- MNN BUILD INFO:
-- System: Linux
-- Processor: x86_64
-- Version: 2.8.2
-- Metal: OFF
-- OpenCL: OFF
-- OpenGL: OFF
-- Vulkan: OFF
-- ARM82: OFF
-- oneDNN: OFF
-- TensorRT: OFF
-- CoreML: OFF
-- NNAPI: OFF
-- CUDA: OFF
-- OpenMP: OFF
-- BF16: OFF
-- ThreadPool: ON
-- Hidden: TRUE
-- Build Path: /datadisk/inspireface/build/ubuntu18_shared/3rdparty/MNN
-- CUDA PROFILE: OFF
-- WIN_USE_ASM:
-- x86_64: Open SSE
-- MNN_AVX512:OFF
-- InspireFace Core:
-- Version: 1.1.4
-- MNN_INCLUDE_DIRS: /datadisk/inspireface/3rdparty/MNN/include
-- MNN_LIBS: MNN
-- ENABLE_TRACKING_BY_DETECTION: OFF
-- ISF_BUILD_SHARED_LIBS: ON
-- ISF_ENABLE_RKNN: OFF
-- InspireFace Project Global:
-- CMAKE_SYSTEM_NAME: Linux
-- CMAKE_BUILD_TYPE: Release
-- ISF_THIRD_PARTY_DIR: /datadisk/inspireface/3rdparty
-- ISF_SANITIZE_ADDRESS: OFF
-- ISF_SANITIZE_LEAK: OFF
-- ISF_ENABLE_RKNN: OFF
-- ISF_BUILD_LINUX_ARM7: OFF
-- ISF_BUILD_LINUX_AARCH64: OFF
-- ISF_BUILD_WITH_TEST: OFF
-- ISF_BUILD_WITH_SAMPLE: OFF
-- OpenCV_DIR: 3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4
-- CMAKE_INSTALL_PREFIX: /datadisk/inspireface/build/ubuntu18_shared/install
-- Configuring done (0.0s)
-- Generating done (0.1s)
-- Build files have been written to: /datadisk/inspireface/build/ubuntu18_shared
[ 0%] Built target MNNMath
[ 0%] Built target MNNCV
[ 1%] Built target MNNUtils
[ 4%] Built target MNN_Express
[ 9%] Built target MNNCore
[ 12%] Built target MNNX8664
[ 15%] Built target MNNAVX
[ 17%] Built target MNNAVXFMA
[ 19%] Built target MNNSSE
[ 74%] Built target MNNCPU
[ 81%] Built target MNNTransform
[ 81%] Built target MNN
[100%] Built target InspireFace
Requirement already satisfied: opencv-python in /home/raj/miniconda3/lib/python3.11/site-packages (4.10.0.84)
Requirement already satisfied: numpy>=1.21.2 in /home/raj/miniconda3/lib/python3.11/site-packages (from opencv-python) (2.0.0)
Requirement already satisfied: click in /home/raj/miniconda3/lib/python3.11/site-packages (8.1.7)
Requirement already satisfied: loguru in /home/raj/miniconda3/lib/python3.11/site-packages (0.7.2)
/datadisk/inspireface/python/inspireface/modules/core/liblibInspireFace.so.so: cannot open shared object file: No such file or directory
/datadisk/inspireface/python/inspireface/modules/core/libInspireFace.so.so: cannot open shared object file: No such file or directory
/home/raj/miniconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /datadisk/inspireface/python/inspireface/modules/core/libInspireFace.so)
/datadisk/inspireface/python/liblibInspireFace.so.so: cannot open shared object file: No such file or directory
/datadisk/inspireface/python/libInspireFace.so.so: cannot open shared object file: No such file or directory
libopencv_highgui.so.410: cannot open shared object file: No such file or directory
Traceback (most recent call last):
File "/datadisk/inspireface/python/sample_face_detection.py", line 3, in
import inspireface as ifac
File "/datadisk/inspireface/python/inspireface/init.py", line 1, in
from .modules import *
File "/datadisk/inspireface/python/inspireface/modules/init.py", line 1, in
from .inspire_face import ImageStream, FaceExtended, FaceInformation, SessionCustomParameter, InspireFaceSession,
File "/datadisk/inspireface/python/inspireface/modules/inspire_face.py", line 5, in
from .core import *
File "/datadisk/inspireface/python/inspireface/modules/core/init.py", line 1, in
from .native import *
File "/datadisk/inspireface/python/inspireface/modules/core/native.py", line 870, in
_libs[_LIBRARY_FILENAME] = load_library(_LIBRARY_FILENAME)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/datadisk/inspireface/python/inspireface/modules/core/native.py", line 558, in call
raise ImportError("Could not load %s." % libname)
ImportError: Could not load libInspireFace.so.

@tunmx
Copy link
Member

tunmx commented Jul 11, 2024

buid is successful but unable to load module file, please suggest.

(base) raj@ryzenbeast:/datadisk/inspireface$ bash ci/quick_test_linux_x86_usual_python_native_interface.sh Directory 'test_res' already exists. Skipping download. Default or fallback case for MNN setup CMake Deprecation Warning at 3rdparty/MNN/CMakeLists.txt:1 (cmake_minimum_required): Compatibility with CMake < 3.5 will be removed from a future version of CMake.

Update the VERSION argument value or use a ... suffix to tell CMake that the project does not need compatibility with older versions.

-- Use Threadpool, forbid openmp -- >>>>>>>>>>>>> -- MNN BUILD INFO: -- System: Linux -- Processor: x86_64 -- Version: 2.8.2 -- Metal: OFF -- OpenCL: OFF -- OpenGL: OFF -- Vulkan: OFF -- ARM82: OFF -- oneDNN: OFF -- TensorRT: OFF -- CoreML: OFF -- NNAPI: OFF -- CUDA: OFF -- OpenMP: OFF -- BF16: OFF -- ThreadPool: ON -- Hidden: TRUE -- Build Path: /datadisk/inspireface/build/ubuntu18_shared/3rdparty/MNN -- CUDA PROFILE: OFF -- WIN_USE_ASM: -- x86_64: Open SSE -- MNN_AVX512:OFF -- InspireFace Core: -- Version: 1.1.4 -- MNN_INCLUDE_DIRS: /datadisk/inspireface/3rdparty/MNN/include -- MNN_LIBS: MNN -- ENABLE_TRACKING_BY_DETECTION: OFF -- ISF_BUILD_SHARED_LIBS: ON -- ISF_ENABLE_RKNN: OFF -- InspireFace Project Global: -- CMAKE_SYSTEM_NAME: Linux -- CMAKE_BUILD_TYPE: Release -- ISF_THIRD_PARTY_DIR: /datadisk/inspireface/3rdparty -- ISF_SANITIZE_ADDRESS: OFF -- ISF_SANITIZE_LEAK: OFF -- ISF_ENABLE_RKNN: OFF -- ISF_BUILD_LINUX_ARM7: OFF -- ISF_BUILD_LINUX_AARCH64: OFF -- ISF_BUILD_WITH_TEST: OFF -- ISF_BUILD_WITH_SAMPLE: OFF -- OpenCV_DIR: 3rdparty/inspireface-precompile/opencv/4.5.1/opencv-ubuntu18-x86/lib/cmake/opencv4 -- CMAKE_INSTALL_PREFIX: /datadisk/inspireface/build/ubuntu18_shared/install -- Configuring done (0.0s) -- Generating done (0.1s) -- Build files have been written to: /datadisk/inspireface/build/ubuntu18_shared [ 0%] Built target MNNMath [ 0%] Built target MNNCV [ 1%] Built target MNNUtils [ 4%] Built target MNN_Express [ 9%] Built target MNNCore [ 12%] Built target MNNX8664 [ 15%] Built target MNNAVX [ 17%] Built target MNNAVXFMA [ 19%] Built target MNNSSE [ 74%] Built target MNNCPU [ 81%] Built target MNNTransform [ 81%] Built target MNN [100%] Built target InspireFace Requirement already satisfied: opencv-python in /home/raj/miniconda3/lib/python3.11/site-packages (4.10.0.84) Requirement already satisfied: numpy>=1.21.2 in /home/raj/miniconda3/lib/python3.11/site-packages (from opencv-python) (2.0.0) Requirement already satisfied: click in /home/raj/miniconda3/lib/python3.11/site-packages (8.1.7) Requirement already satisfied: loguru in /home/raj/miniconda3/lib/python3.11/site-packages (0.7.2) /datadisk/inspireface/python/inspireface/modules/core/liblibInspireFace.so.so: cannot open shared object file: No such file or directory /datadisk/inspireface/python/inspireface/modules/core/libInspireFace.so.so: cannot open shared object file: No such file or directory /home/raj/miniconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /datadisk/inspireface/python/inspireface/modules/core/libInspireFace.so) /datadisk/inspireface/python/liblibInspireFace.so.so: cannot open shared object file: No such file or directory /datadisk/inspireface/python/libInspireFace.so.so: cannot open shared object file: No such file or directory libopencv_highgui.so.410: cannot open shared object file: No such file or directory Traceback (most recent call last): File "/datadisk/inspireface/python/sample_face_detection.py", line 3, in import inspireface as ifac File "/datadisk/inspireface/python/inspireface/init.py", line 1, in from .modules import * File "/datadisk/inspireface/python/inspireface/modules/init.py", line 1, in from .inspire_face import ImageStream, FaceExtended, FaceInformation, SessionCustomParameter, InspireFaceSession, File "/datadisk/inspireface/python/inspireface/modules/inspire_face.py", line 5, in from .core import * File "/datadisk/inspireface/python/inspireface/modules/core/init.py", line 1, in from .native import * File "/datadisk/inspireface/python/inspireface/modules/core/native.py", line 870, in _libs[_LIBRARY_FILENAME] = load_library(_LIBRARY_FILENAME) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/datadisk/inspireface/python/inspireface/modules/core/native.py", line 558, in call raise ImportError("Could not load %s." % libname) ImportError: Could not load libInspireFace.so.

Based on your log, it is confirmed that your GLIBCXX version is too low(At least GLIBCXX_3.4.32 is required.). It usually depends on libstdc++, which you can install or upgrade on your computer. It is worth noting that the path indicating the low version is within the miniconda directory. You can check if the system's GLIBCXX meets the requirements, and if it does, you can manually replace the GLIBCXX in the miniconda directory.

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