Hard requirement for cuda?
GloriousEggroll opened this issue · 2 comments
I'm trying to build this as an rpm package for fedora, but it seems to have hard coded rpaths that require cuda:
ERROR 0002: file '/usr/lib64/obs-plugins/obs-backgroundremoval/libonnxruntime.so.1.17.1' contains an invalid rpath '/usr/local/cuda-11.8/lib64' in [$ORIGIN:/usr/local/cuda-11.8/lib64:]
ERROR 0010: file '/usr/lib64/obs-plugins/obs-backgroundremoval/libonnxruntime.so.1.17.1' contains an empty rpath in [$ORIGIN:/usr/local/cuda-11.8/lib64:]
ERROR 0002: file '/usr/lib64/obs-plugins/obs-backgroundremoval/libonnxruntime_providers_cuda.so' contains an invalid rpath '/usr/local/cuda-11.8/lib' in [/usr/local/cuda-11.8/lib:]
ERROR 0010: file '/usr/lib64/obs-plugins/obs-backgroundremoval/libonnxruntime_providers_cuda.so' contains an empty rpath in [/usr/local/cuda-11.8/lib:]
Does this absolutely require cuda to function properly? I didn't see any mention of cuda as a hard requirement in the readme.
Nevermind figured it out.
The bundled onnxruntime libraries with the default build options from #581 force cuda rpaths.
There's a few things to fix. --
- I was messing with the ROCM PR here:
And without the CMakeList changes there for using system onnxruntime it would not detect onnxruntime on my system even though I had onnxruntime-devel installed. So, I recommend porting that portion of that patch over.
- After that, I enabled:
-DUSE_SYSTEM_ONNXRUNTIME=ON \
And build requirements:
BuildRequires: onnxruntime-devel
And requirements:
Requires: onnxruntime
However, that kept wanting to use:
OrtSessionOptionsAppendExecutionProvider_Tensorrt
Which of course relies on cuda, so I also did:
-DDISABLE_ONNXRUNTIME_GPU=ON \
That allowed it to fully work and build on Fedora via my spec sheet.
Here's the relevant parts of my spec sheet:
Name: obs-studio-plugin-backgroundremoval
Version: 1.1.13
Release: 1%{?dist}
Summary: A plugin for OBS Studio that allows you to replace the background in portrait images and video, as well as enhance low-light scenes.
License: GPL-2.0-or-later
URL: https://github.com/occ-ai/obs-backgroundremoval
Source0: https://github.com/occ-ai/obs-backgroundremoval/archive/refs/tags/%{version}.tar.gz
# ROCM support
Patch0: 545.patch
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: cmake(libobs)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: curl-devel
BuildRequires: opencv-devel
BuildRequires: onnxruntime-devel
Requires: opencv-core
Requires: onnxruntime
Supplements: obs-studio%{?_isa}
%description
%{name}.
%prep
%autosetup -n obs-backgroundremoval-%{version} -p1
%build
%cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DENABLE_FRONTEND_API=ON \
-DENABLE_QT=OFF \
-DENABLE_ROCM=OFF \
-DUSE_SYSTEM_ONNXRUNTIME=ON \
-DDISABLE_ONNXRUNTIME_GPU=ON \
-DUSE_SYSTEM_OPENCV=ON
%cmake_build
%install
%cmake_install --prefix /usr
%files
%license LICENSE
%{_libdir}/obs-plugins/obs-backgroundremoval*
%{_datadir}/obs/obs-plugins/obs-backgroundremoval*
%changelog
* Wed Jun 05 2024 Tom Crider <gloriouseggroll@gmail.com>
- Initial build 1.1.13
This should be enough for a clean Fedora rpm build without relying on cuda or rocm
Thank you for sharing!