Skip to content

Instantly share code, notes, and snippets.

@fritz-fritz
Last active May 5, 2025 21:31
Show Gist options
  • Save fritz-fritz/b8dd3cc081325d1a73e86be727edc0f7 to your computer and use it in GitHub Desktop.
Save fritz-fritz/b8dd3cc081325d1a73e86be727edc0f7 to your computer and use it in GitHub Desktop.
Custom obs-backgroundremoval build with support for NVIDIA cuda 12 on linux

The below CMakeUserPreset.json can be used to successfully build and install obs-backgroundremoval with a version of the ONNXRUNTIME that supports current NVIDIA CUDA 12.

It makes use of changes introduced in my fork with commit 2c658d8a. EDIT: The PR has now been merged into master

Due to changes upstream with ONNXRUNTIME, the plugin now depends on libcudnn for CUDA which is provided by nvidia-cudnn.

To make use of this:

  1. Clone from my fork on the feature/custom-onnxruntime branch. Clone locaal-ai/obs-backgroundremoval
  2. Place the below CMakeUserPresets.json file at the projects root
  3. Run the following:
    rm -rf build_x86_64 release \
      && cmake --preset cuda12 \
      && cmake --build --preset cuda12 \
      && cmake --build build_x86_64 -t package \
      && sudo apt install ./release/obs-backgroundremoval-1.2.0-x86_64-linux-gnu.deb
  4. Profit
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 28,
"patch": 0
},
"configurePresets": [
{
"name": "cuda12",
"displayName": "Linux x86_64 w/ cuda12",
"description": "Build for Linux x86_64 against CUDA 12",
"inherits": ["template"],
"binaryDir": "${sourceDir}/build_x86_64",
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"generator": "Ninja",
"warnings": {"dev": true, "deprecated": true},
"cacheVariables": {
"QT_VERSION": "6",
"CMAKE_INSTALL_PREFIX": "/usr",
"CMAKE_BUILD_TYPE": "Release",
"CPACK_DEBIAN_PACKAGE_DEPENDS": "obs-studio, nvidia-driver, nvidia-cuda-toolkit | cuda, nvidia-cudnn | cudnn",
"CUSTOM_ONNXRUNTIME_VERSION": "1.21.0",
"CUSTOM_ONNXRUNTIME_URL": "https://github.com/microsoft/onnxruntime/releases/download/v1.21.0/onnxruntime-linux-x64-gpu-1.21.0.tgz",
"CUSTOM_ONNXRUNTIME_HASH": "SHA256=ef37a33ba75e457aebfd0d7b342ab20424aa6126bc5f565d247f1201b66996cf"
}
}
],
"buildPresets": [
{
"name": "cuda12",
"configurePreset": "cuda12",
"displayName": "Linux x86_64 w/ cuda12",
"description": "Linux build for x86_64 against CUDA 12",
"configuration": "Release"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment