Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 config, 3 stdenv, 4 lib, 5 fetchurl, 6 fetchpatch, 7 bash, 8 cmake, 9 opencv4, 10 gtest, 11 blas, 12 gomp, 13 llvmPackages, 14 perl, 15 # mxnet cuda support is turned off, but dependencies like opencv can still be built with cudaSupport 16 # and fail to compile without the cudatoolkit 17 # mxnet cuda support will not be available, as mxnet requires version <=11 18 cudaSupport ? config.cudaSupport, 19 cudaPackages ? { }, 20}: 21 22# mxnet is not maintained, and other projects are migrating away from it. 23# https://github.com/apache/mxnet/issues/21206 24 25stdenv.mkDerivation rec { 26 pname = "mxnet"; 27 version = "1.9.1"; 28 29 src = fetchurl { 30 name = "apache-mxnet-src-${version}-incubating.tar.gz"; 31 url = "mirror://apache/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz"; 32 hash = "sha256-EephMoF02MKblvNBl34D3rC/Sww3rOZY+T442euMkyI="; 33 }; 34 35 patches = [ 36 # Remove the following two patches when updating mxnet to 2.0. 37 (fetchpatch { 38 name = "1-auto-disable-sse-for-non-x86.patch"; 39 url = "https://github.com/apache/incubator-mxnet/commit/55e69871d4cadec51a8bbb6700131065388cb0b9.patch"; 40 hash = "sha256-uaMpM0F9HRtEBXz2ewB/dlbuKaY5/RineCPUE2T6CHU="; 41 }) 42 (fetchpatch { 43 name = "2-auto-disable-sse-for-non-x86.patch"; 44 url = "https://github.com/apache/incubator-mxnet/commit/c1b96f562f55dfa024ac941d7b104f00e239ee0f.patch"; 45 excludes = [ "ci/docker/runtime_functions.sh" ]; 46 hash = "sha256-r1LbC8ueRooW5tTNakAlRSJ+9aR4WXXoEKx895DgOs4="; 47 }) 48 ]; 49 50 nativeBuildInputs = [ 51 cmake 52 perl 53 ]; 54 55 buildInputs = [ 56 opencv4 57 gtest 58 blas.provider 59 ] 60 ++ lib.optional stdenv.cc.isGNU gomp 61 ++ lib.optional stdenv.cc.isClang llvmPackages.openmp 62 ++ lib.optionals cudaSupport [ 63 # needed for OpenCV cmake module 64 cudaPackages.cudatoolkit 65 ]; 66 67 cmakeFlags = [ 68 "-DUSE_MKL_IF_AVAILABLE=OFF" 69 "-DUSE_CUDA=OFF" 70 "-DUSE_CUDNN=OFF" 71 ]; 72 73 env.NIX_CFLAGS_COMPILE = toString [ 74 # Needed with GCC 12 75 "-Wno-error=uninitialized" 76 ]; 77 78 postPatch = '' 79 substituteInPlace 3rdparty/mkldnn/tests/CMakeLists.txt \ 80 --replace "/bin/bash" "${bash}/bin/bash" 81 82 # Build against the system version of OpenMP. 83 # https://github.com/apache/incubator-mxnet/pull/12160 84 rm -rf 3rdparty/openmp 85 ''; 86 87 postInstall = '' 88 rm "$out"/lib/*.a 89 ''; 90 91 meta = with lib; { 92 description = "Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler"; 93 homepage = "https://mxnet.incubator.apache.org/"; 94 maintainers = with maintainers; [ abbradar ]; 95 license = licenses.asl20; 96 platforms = platforms.linux; 97 }; 98}