Change:
Project description ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator . Onnxruntime is already packaged. I would like to have the version with gpu support to be able to package obs-backgroundremoval with gpu support (). Related: Metadata homepage URL: source URL: license: mit platforms: linux
Obs-backgroundremoval includes tensorrtproviderfactory.h to build
need it, too
Is it possible to add gpu support to the obs-backgroundremoval as this issue is closed?
It may be possible. If anyone wants to open a PR for that, please base it on the current update PR

Discussion:
{ lib , stdenv , fetchFromGitHub <ins> , fetchpatch </ins> , cmake , gtest , pkg-config

# error: unsafe buffer access env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-unsafe-buffer-usage"; <ins> patches = [ # nvcc doesn't recognize the "gsl" attribute namespace (microsoft/onnxruntime#13573) # only affects nvcc (fetchpatch { url = "https://raw.githubusercontent.com/microsoft/onnxruntime/4bfa69def85476b33ccfaf68cf070f3fb65d39f7/cmake/patches/gsl/1064.patch"; hash = "sha256-0jESA+VENWQms9HGE0jRiZZuWLJehBlbArxSaQbYOrM="; }) ]; </ins> doCheck = true; meta = with lib; {

<del> { stdenv </del> <ins> { config , stdenv </ins> , lib , fetchFromGitHub <del> , fetchFromGitLab </del> , Foundation , abseil-cpp , cmake

, iconv , protobuf_21 , pythonSupport ? true <del> }: </del> <ins> , cudaSupport ? config.cudaSupport , cudaPackages ? {} }@inputs: </ins> let <ins> version = "1.16.3"; stdenv = throw "Use effectiveStdenv instead"; effectiveStdenv = if cudaSupport then cudaPackages.backendStdenv else inputs.stdenv; cudaCapabilities = cudaPackages.cudaFlags.cudaCapabilities; # E.g. [ "80" "86" "90" ] cudaArchitectures = (builtins.map cudaPackages.cudaFlags.dropDot cudaCapabilities); cudaArchitecturesString = lib.strings.concatStringsSep ";" cudaArchitectures; </ins> howard-hinnant-date = fetchFromGitHub { owner = "HowardHinnant"; repo = "date";

rev = "refs/tags/v1.14.1"; hash = "sha256-ZVSdk6LeAiZpQrrzLxphMbc1b3rNUMpcxcXPP8s/5tE="; }; <ins> cutlass = fetchFromGitHub { owner = "NVIDIA"; repo = "cutlass"; rev = "v3.0.0"; sha256 = "sha256-YPD5Sy6SvByjIcGtgeGH80TEKg2BtqJWSg46RvnJChY="; }; </ins> in <del> stdenv.mkDerivation rec { </del> <ins> effectiveStdenv.mkDerivation rec { </ins> pname = "onnxruntime"; <del> version = "1.16.3"; </del> <ins> inherit version; </ins> src = fetchFromGitHub { owner = "microsoft";

# - use MakeAvailable instead of the low-level Populate, # - use Eigen3::Eigen as the target name (as declared by libeigen/eigen). ./0001-eigen-allow-dependency-injection.patch <ins> ] ++ lib.optionals cudaSupport [ # We apply the referenced 1064.patch ourselves to our nix dependency. #  FIND_PACKAGE_ARGS for CUDA was added in https://github.com/microsoft/onnxruntime/commit/87744e5 so it might be possible to delete this patch after upgrading to 1.17.0 ./nvcc-gsl.patch </ins> ]; nativeBuildInputs = [

pythonOutputDistHook setuptools wheel <del> ]); </del> <ins> ]) ++ lib.optionals cudaSupport [ cudaPackages.cuda_nvcc ]; </ins> buildInputs = [ eigen

nlohmann_json microsoft-gsl ] ++ lib.optionals pythonSupport (with python3Packages; [ <ins> gtest' </ins> numpy pybind11 packaging <del> ]) ++ lib.optionals stdenv.isDarwin [ </del> <ins> ]) ++ lib.optionals effectiveStdenv.isDarwin [ </ins> Foundation iconv <del> ]; </del> <ins> ] ++ lib.optionals cudaSupport (with cudaPackages; [ cuda_cccl # cub/cub.cuh libcublas # cublas_v2.h libcurand # curand.h libcusparse # cusparse.h libcufft # cufft.h cudnn # cudnn.h cuda_cudart ]); </ins> nativeCheckInputs = lib.optionals pythonSupport (with python3Packages; [ <del> gtest' </del> pytest sympy onnx

"-Donnxruntime_BUILD_UNIT_TESTS=ON" "-Donnxruntime_ENABLE_LTO=ON" "-Donnxruntime_USE_FULL_PROTOBUF=OFF" <ins> (lib.cmakeBool "onnxruntime_USE_CUDA" cudaSupport) (lib.cmakeBool "onnxruntime_USE_NCCL" cudaSupport) </ins> ] ++ lib.optionals pythonSupport [ "-Donnxruntime_ENABLE_PYTHON=ON" <ins> ] ++ lib.optionals cudaSupport [ (lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_CUTLASS" cutlass) (lib.cmakeFeature "onnxruntime_CUDNN_HOME" cudaPackages.cudnn) (lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" cudaArchitecturesString) </ins> ]; <del> env = lib.optionalAttrs stdenv.cc.isClang { </del> <ins> env = lib.optionalAttrs effectiveStdenv.cc.isClang { </ins> NIX_CFLAGS_COMPILE = toString [ "-Wno-error=deprecated-declarations" "-Wno-error=unused-but-set-variable" ]; }; <del> doCheck = true; </del> <ins> doCheck = !cudaSupport; requiredSystemFeatures = lib.optionals cudaSupport [ "big-parallel" ]; </ins> postPatch = '' substituteInPlace cmake/libonnxruntime.pc.cmake.in  --replace-fail '$'{prefix}/@CMAKE_INSTALL_ @CMAKE_INSTALL_ <del> '' + lib.optionalString (stdenv.hostPlatform.system == "aarch64-linux") '' </del> <ins> '' + lib.optionalString (effectiveStdenv.hostPlatform.system == "aarch64-linux") '' </ins> # https://github.com/NixOS/nixpkgs/pull/226734#issuecomment-1663028691 rm -v onnxruntime/test/optimizer/nhwc_transformer_test.cc '';

<ins> diff --git a/cmake/external/onnxruntime_external_deps.cmake b/cmake/external/onnxruntime_external_deps.cmake index 9effd1a2db..faff5e8de7 100644 --- a/cmake/external/onnxruntime_external_deps.cmake +++ b/cmake/external/onnxruntime_external_deps.cmake @@ -280,21 +280,12 @@ if (NOT WIN32) endif() endif() -if(onnxruntime_USE_CUDA) -  FetchContent_Declare( -    GSL -    URL ${DEP_URL_microsoft_gsl} -    URL_HASH SHA1=${DEP_SHA1_microsoft_gsl} -    PATCH_COMMAND ${Patch_EXECUTABLE} --binary --ignore-whitespace -p1 < ${PROJECT_SOURCE_DIR}/patches/gsl/1064.patch -  ) -else() -  FetchContent_Declare( -    GSL -    URL ${DEP_URL_microsoft_gsl} -    URL_HASH SHA1=${DEP_SHA1_microsoft_gsl} -    FIND_PACKAGE_ARGS 4.0 NAMES Microsoft.GSL -  ) -endif() +FetchContent_Declare( +  GSL +  URL ${DEP_URL_microsoft_gsl} +  URL_HASH SHA1=${DEP_SHA1_microsoft_gsl} +  FIND_PACKAGE_ARGS 4.0 NAMES Microsoft.GSL +) FetchContent_Declare( safeint </ins>