1 { config, stdenv, lib, fetchurl, fetchpatch, bash, cmake
2 , opencv4, gtest, blas, gomp, llvmPackages, perl
3 , cudaSupport ? config.cudaSupport, cudaPackages ? { }, nvidia_x11
4 , cudnnSupport ? cudaSupport
8 inherit (cudaPackages) backendStdenv cudatoolkit cudaFlags cudnn;
11 assert cudnnSupport -> cudaSupport;
13 stdenv.mkDerivation rec {
18 name = "apache-mxnet-src-${version}-incubating.tar.gz";
19 url = "mirror://apache/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
20 hash = "sha256-EephMoF02MKblvNBl34D3rC/Sww3rOZY+T442euMkyI=";
24 # Remove the following two patches when updating mxnet to 2.0.
26 name = "1-auto-disable-sse-for-non-x86.patch";
27 url = "https://github.com/apache/incubator-mxnet/commit/55e69871d4cadec51a8bbb6700131065388cb0b9.patch";
28 hash = "sha256-uaMpM0F9HRtEBXz2ewB/dlbuKaY5/RineCPUE2T6CHU=";
31 name = "2-auto-disable-sse-for-non-x86.patch";
32 url = "https://github.com/apache/incubator-mxnet/commit/c1b96f562f55dfa024ac941d7b104f00e239ee0f.patch";
33 excludes = ["ci/docker/runtime_functions.sh"];
34 hash = "sha256-r1LbC8ueRooW5tTNakAlRSJ+9aR4WXXoEKx895DgOs4=";
38 nativeBuildInputs = [ cmake perl ];
40 buildInputs = [ opencv4 gtest blas.provider ]
41 ++ lib.optional stdenv.cc.isGNU gomp
42 ++ lib.optional stdenv.cc.isClang llvmPackages.openmp
43 # FIXME: when cuda build is fixed, remove nvidia_x11, and use /run/opengl-driver/lib
44 ++ lib.optionals cudaSupport [ cudatoolkit nvidia_x11 ]
45 ++ lib.optional cudnnSupport cudnn;
48 [ "-DUSE_MKL_IF_AVAILABLE=OFF" ]
49 ++ (if cudaSupport then [
50 "-DUSE_OLDCMAKECUDA=ON" # see https://github.com/apache/incubator-mxnet/issues/10743
51 "-DCUDA_ARCH_NAME=All"
52 "-DCUDA_HOST_COMPILER=${backendStdenv.cc}/bin/cc"
53 "-DMXNET_CUDA_ARCH=${builtins.concatStringsSep ";" cudaFlags.realArches}"
54 ] else [ "-DUSE_CUDA=OFF" ])
55 ++ lib.optional (!cudnnSupport) "-DUSE_CUDNN=OFF";
57 env.NIX_CFLAGS_COMPILE = toString [
59 "-Wno-error=uninitialized"
63 substituteInPlace 3rdparty/mkldnn/tests/CMakeLists.txt \
64 --replace "/bin/bash" "${bash}/bin/bash"
66 # Build against the system version of OpenMP.
67 # https://github.com/apache/incubator-mxnet/pull/12160
68 rm -rf 3rdparty/openmp
75 # used to mark cudaSupport in python310Packages.mxnet as broken;
76 # other attributes exposed for consistency
78 inherit cudaSupport cudnnSupport cudatoolkit cudnn;
82 description = "Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler";
83 homepage = "https://mxnet.incubator.apache.org/";
84 maintainers = with maintainers; [ abbradar ];
85 license = licenses.asl20;
86 platforms = platforms.unix;
87 # Build failures when linking mxnet_unit_tests: https://gist.github.com/6d17447ee3557967ec52c50d93b17a1d