occ-ai / obs-backgroundremoval

An OBS plugin for removing background in portrait images (video), making it easy to replace the background when recording or streaming.
GNU General Public License v2.0
2.7k stars 185 forks source link

issues loading onnx runtime on arch #504

Closed AskAlice closed 6 months ago

AskAlice commented 6 months ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce unsure, but all i need to do is enable tensorrt and look at the logs

Expected behavior it works

Screenshots

Log and Crash Report

info: [obs-backgroundremoval]   Model file path: s�
error: [obs-backgroundremoval] /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1193 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_tensorrt.so with error: libnvinfer.so.8: cannot open shared object file: No such file or directory

error: [obs-backgroundremoval] Failed to create ONNXRuntime session. Error code: 5
umireon commented 6 months ago

Please fill the issue template fully

royshil commented 6 months ago

The error indicate a missing file libnvinfer.so.8

There's some helpful info here https://stackoverflow.com/questions/62060682/installing-tensorrt-facing-issue-with-libnvinfer7-library-cuda-10-2-on-ubuntu

tensorrt needs to be installed properly

umireon commented 6 months ago

@royshil Can we close this issue as stalled?

royshil commented 6 months ago

stalled.

AskAlice commented 4 months ago
❯ yay -Ss onnxruntime | grep Installed
extra/python-onnxruntime 1.16.3-5 (92.4 MiB 989.7 MiB) (Installed)
extra/onnxruntime 1.16.3-5 (61.6 MiB 857.0 MiB) (Installed)
❯ yay -Ss tensorrt | grep Installed
aur/python-tensorrt 9.3.0.1-1 (+15 0.72) (Installed)
aur/tensorrt 9.3.0.1-1 (+15 0.72) (Installed)
❯ pacman -Ss cuda | grep installed
core/icu 74.2-1 [installed]
extra/cuda 12.3.2-1 [installed]
extra/cudnn 8.9.7.29-1 [installed]
extra/magma-cuda 2.7.2-3 [installed]
extra/opencv-cuda 4.9.0-2 [installed]
extra/python-pytorch-opt-cuda 2.2.0-1 [installed]
extra/python-torchvision-cuda 0.17.0-1 [installed]
multilib/lib32-icu 74.2-1 [installed]
AskAlice commented 4 months ago

modifying the AUR package obs-backgroundremoval-git to set -DUSE_SYSTEM_ONNXRUNTIME=ON yields

❯ makepkg -si
==> Making package: obs-backgroundremoval-git 1.1.8.r1.d77ff28-1 (Sun 18 Feb 2024 07:09:11 PM MST)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating obs-backgroundremoval git repo...
==> Validating source files with sha256sums...
    obs-backgroundremoval ... Skipped
==> Extracting sources...
  -> Creating working copy of obs-backgroundremoval git repo...
Reset branch 'makepkg'
==> Starting pkgver()...
==> Updated version: obs-backgroundremoval-git 1.1.10.r7.e226085-1
==> Removing existing $pkgdir/ directory...
==> Starting build()...
Preset CMake variables:

  CMAKE_BUILD_TYPE="RelWithDebInfo"
  CMAKE_POSITION_INDEPENDENT_CODE:BOOL="TRUE"
  ENABLE_FRONTEND_API:BOOL="TRUE"
  ENABLE_QT:BOOL="FALSE"
  QT_VERSION="6"

CMake Error at CMakeLists.txt:51 (find_package):
  By not providing "FindOnnxruntime.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "Onnxruntime", but CMake did not find one.

  Could not find a package configuration file provided by "Onnxruntime"
  (requested version 1.16.3) with any of the following names:

    OnnxruntimeConfig.cmake
    onnxruntime-config.cmake

  Add the installation prefix of "Onnxruntime" to CMAKE_PREFIX_PATH or set
  "Onnxruntime_DIR" to a directory containing one of the above files.  If
  "Onnxruntime" provides a separate development package or SDK, be sure it
  has been installed.
AskAlice commented 4 months ago

it seems like a version mismatch, however as i'm on arch it's not exactly straight-forward to downgrade tensorrt

error: [obs-backgroundremoval] /onnxruntime_src/onnxruntime/core/session/provider_bridge_ort.cc:1193 onnxruntime::Provider& onnxruntime::ProviderLibrary::Get() [ONNXRuntimeError] : 1 : FAIL : Failed to load library libonnxruntime_providers_tensorrt.so with error: libnvinfer.so.8: cannot open shared object file: No such file or directory
❯ pacman -Ql tensorrt | grep libnvinfer
tensorrt /usr/lib/libnvinfer.so
tensorrt /usr/lib/libnvinfer.so.9
tensorrt /usr/lib/libnvinfer.so.9.3.0
tensorrt /usr/lib/libnvinfer_builder_resource.so
tensorrt /usr/lib/libnvinfer_builder_resource.so.9
tensorrt /usr/lib/libnvinfer_builder_resource.so.9.3.0
tensorrt /usr/lib/libnvinfer_dispatch.so
tensorrt /usr/lib/libnvinfer_dispatch.so.9
tensorrt /usr/lib/libnvinfer_dispatch.so.9.3.0
tensorrt /usr/lib/libnvinfer_dispatch_static.a
tensorrt /usr/lib/libnvinfer_lean.so
tensorrt /usr/lib/libnvinfer_lean.so.9
tensorrt /usr/lib/libnvinfer_lean.so.9.3.0
tensorrt /usr/lib/libnvinfer_lean_static.a
tensorrt /usr/lib/libnvinfer_plugin.so
tensorrt /usr/lib/libnvinfer_plugin.so.9
tensorrt /usr/lib/libnvinfer_plugin.so.9.2.0
tensorrt /usr/lib/libnvinfer_plugin_static.a
tensorrt /usr/lib/libnvinfer_static.a
tensorrt /usr/lib/libnvinfer_vc_plugin.so
tensorrt /usr/lib/libnvinfer_vc_plugin.so.9
tensorrt /usr/lib/libnvinfer_vc_plugin.so.9.2.0
tensorrt /usr/lib/libnvinfer_vc_plugin_static.a
AskAlice commented 4 months ago

@umireon ?

umireon commented 4 months ago

Can you try to build our plugin without using AUR definition?

AskAlice commented 4 months ago

i actually tried that first, and got the same result. however i disabled the flag and got this.

I also followed the fedora build instructions and it did pretty much what this is doing

❯ sudo cmake --install build_x86_64 --prefix /usr
-- Install configuration: "RelWithDebInfo"
-- Installing: /usr/lib/obs-plugins/obs-backgroundremoval/libonnxruntime.so.1.16.3
-- Installing: /usr/lib/obs-plugins/obs-backgroundremoval/libonnxruntime_providers_shared.so
-- Installing: /usr/lib/obs-plugins/obs-backgroundremoval/libonnxruntime_providers_cuda.so
-- Installing: /usr/lib/obs-plugins/obs-backgroundremoval/libonnxruntime_providers_tensorrt.so
-- Installing: /usr/lib/obs-plugins/obs-backgroundremoval.so
-- Set non-toolchain portion of runtime path of "/usr/lib/obs-plugins/obs-backgroundremoval.so" to "$ORIGIN/obs-backgroundremoval"
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/config.json
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/effects
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/effects/blend_images.effect
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/effects/kawase_blur.effect
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/effects/mask_alpha_filter.effect
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/ar-EG.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/bn-IN.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/en-US.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/es-SP.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/fr-FR.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/hi-IN.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/it-IT.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/ja-JP.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/ko-KR.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/pt-BR.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/ru-RU.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/ta-IN.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/tr-TR.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/locale/zh-CN.ini
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/SINet_Softmax_simple.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/mediapipe.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/pphumanseg_fp32.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/rvm_mobilenetv3_fp32.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/selfie_segmentation.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/semantic_guided_llie_180x324.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/tbefn_fp32.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/tcmonodepth_tcsmallnet_192x320.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/uretinex_net_180x320.onnx
-- Up-to-date: /usr/share/obs/obs-plugins/obs-backgroundremoval/models/zero_dce_180x320.onnx

❯ stat /usr/lib/obs-plugins/obs-backgroundremoval.so
  File: /usr/lib/obs-plugins/obs-backgroundremoval.so
  Size: 15837576        Blocks: 30936      IO Block: 4096   regular file
Device: 0,28    Inode: 19132400    Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-02-19 06:22:41.379996184 -0700
Modify: 2024-02-19 06:19:13.000000000 -0700
Change: 2024-02-19 06:22:30.673839166 -0700
 Birth: 2024-02-19 06:22:30.672839152 -0700```
AskAlice commented 4 months ago

far from the cleanest approach but I simply symlinked libnvinfer.so.9 and related files to .8 and it fired right up

sudo cd /usr/lib/
sudo ln -S libnvinfer.so libnvinfer.so.8
sudo ln -s libnvinfer.so libnvinfer.so.8
sudo ln -s libnvinfer_plugin.so libnvinfer_plugin.so.8
sudo ln -s libnvinfer_dispatch.so libnvinfer_dispatch.so.8
sudo ln -s libnvonnxparser.so libnvonnxparser.so.8