onnxruntime: fix cuda by patching protobuf
This commit is contained in:
@@ -39,6 +39,29 @@ let
|
||||
|
||||
cudaArchitecturesString = cudaPackages.flags.cmakeCudaArchitecturesString;
|
||||
|
||||
# While onnxruntime suggests using (3 year-old) protobuf 21.12
|
||||
# https://github.com/microsoft/onnxruntime/blob/v1.23.2/cmake/deps.txt#L40, using a newer
|
||||
# protobuf version is possible.
|
||||
# We still need to patch the nixpkgs protobuf (32.1) to address the following test failure that
|
||||
# occurs when cudaSupport is enabled:
|
||||
# [libprotobuf ERROR /build/source/src/google/protobuf/descriptor_database.cc:642] File already exists in database: onnx/onnx-ml.proto
|
||||
# [libprotobuf FATAL /build/source/src/google/protobuf/descriptor.cc:1986] CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):
|
||||
# terminate called after throwing an instance of 'google::protobuf::FatalException'
|
||||
# what(): CHECK failed: GeneratedDatabase()->Add(encoded_file_descriptor, size):
|
||||
#
|
||||
#
|
||||
# Caused by: https://github.com/protocolbuffers/protobuf/commit/8f7aab29b21afb89ea0d6e2efeafd17ca71486a9
|
||||
# Reported upstream: https://github.com/protocolbuffers/protobuf/issues/21542
|
||||
protobuf' = protobuf.overrideAttrs (old: {
|
||||
patches = (old.patches or [ ]) ++ [
|
||||
(fetchpatch {
|
||||
name = "Workaround nvcc bug in message_lite.h";
|
||||
url = "https://raw.githubusercontent.com/conda-forge/protobuf-feedstock/737a13ea0680484c08e8e0ab0144dab82c10c1b3/recipe/patches/0010-Workaround-nvcc-bug-in-message_lite.h.patch";
|
||||
hash = "sha256-joK50Il4mrwIc6zuNW9gDIfOx9LuA4FlusJuzUf9kqI=";
|
||||
})
|
||||
];
|
||||
});
|
||||
|
||||
# TODO: update the following dependencies according to:
|
||||
# https://github.com/microsoft/onnxruntime/blob/v<VERSION>/cmake/deps.txt
|
||||
|
||||
@@ -134,7 +157,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||
cmake
|
||||
pkg-config
|
||||
python3Packages.python
|
||||
protobuf
|
||||
protobuf'
|
||||
]
|
||||
++ lib.optionals pythonSupport (
|
||||
with python3Packages;
|
||||
@@ -247,7 +270,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||
(lib.cmakeFeature "FETCHCONTENT_SOURCE_DIR_SAFEINT" "${safeint-src}")
|
||||
(lib.cmakeFeature "FETCHCONTENT_TRY_FIND_PACKAGE_MODE" "ALWAYS")
|
||||
# fails to find protoc on darwin, so specify it
|
||||
(lib.cmakeFeature "ONNX_CUSTOM_PROTOC_EXECUTABLE" (lib.getExe protobuf))
|
||||
(lib.cmakeFeature "ONNX_CUSTOM_PROTOC_EXECUTABLE" (lib.getExe protobuf'))
|
||||
(lib.cmakeBool "onnxruntime_BUILD_SHARED_LIB" true)
|
||||
(lib.cmakeBool "onnxruntime_BUILD_UNIT_TESTS" finalAttrs.doCheck)
|
||||
(lib.cmakeBool "onnxruntime_USE_FULL_PROTOBUF" withFullProtobuf)
|
||||
@@ -351,7 +374,7 @@ effectiveStdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
passthru = {
|
||||
inherit cudaSupport cudaPackages ncclSupport; # for the python module
|
||||
inherit protobuf;
|
||||
protobuf = protobuf';
|
||||
tests = lib.optionalAttrs pythonSupport {
|
||||
python = python3Packages.onnxruntime;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user