From 813c400edc0802a16c9c4b305f111b7f9b22c537 Mon Sep 17 00:00:00 2001 From: Ryan Burns Date: Thu, 23 Sep 2021 01:40:27 -0700 Subject: [PATCH] cntk: fix build with protobuf 3.18+ --- .../science/math/cntk/default.nix | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkgs/applications/science/math/cntk/default.nix b/pkgs/applications/science/math/cntk/default.nix index c007490c94d0..ba2225b903fa 100644 --- a/pkgs/applications/science/math/cntk/default.nix +++ b/pkgs/applications/science/math/cntk/default.nix @@ -1,4 +1,5 @@ { lib, stdenv, fetchgit, fetchFromGitHub, cmake +, fetchpatch , openblas, blas, lapack, opencv3, libzip, boost, protobuf, mpi , onebitSGDSupport ? false , cudaSupport ? false, addOpenGLRunpath, cudatoolkit, nvidia_x11 @@ -28,6 +29,26 @@ in stdenv.mkDerivation rec { sha256 = "18l9k7s966a26ywcf7flqyhm61788pcb9fj3wk61jrmgkhy2pcns"; }; + patches = [ + # Fix build with protobuf 3.18+ + # Remove with onnx submodule bump to 1.9+ + (fetchpatch { + url = "https://github.com/onnx/onnx/commit/d3bc82770474761571f950347560d62a35d519d7.patch"; + extraPrefix = "Source/CNTKv2LibraryDll/proto/onnx/onnx_repo/"; + stripLen = 1; + sha256 = "00raqj8wx30b06ky6cdp5vvc1mrzs7hglyi6h58hchw5lhrwkzxp"; + }) + ]; + + postPatch = '' + # Fix build with protobuf 3.18+ + substituteInPlace Source/CNTKv2LibraryDll/Serialization.cpp \ + --replace 'SetTotalBytesLimit(INT_MAX, INT_MAX)' \ + 'SetTotalBytesLimit(INT_MAX)' \ + --replace 'SetTotalBytesLimit(limit, limit)' \ + 'SetTotalBytesLimit(limit)' + ''; + nativeBuildInputs = [ cmake ] ++ lib.optional cudaSupport addOpenGLRunpath; # Force OpenMPI to use g++ in PATH.