2021-11-28 03:11:09 +00:00
|
|
|
{ config, stdenv, lib, fetchurl, fetchpatch, bash, cmake
|
|
|
|
, opencv3, gtest, blas, gomp, llvmPackages, perl
|
2019-02-03 15:32:14 +00:00
|
|
|
, cudaSupport ? config.cudaSupport or false, cudatoolkit, nvidia_x11
|
|
|
|
, cudnnSupport ? cudaSupport, cudnn
|
2017-09-16 02:39:25 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "mxnet";
|
2021-11-28 22:26:11 +00:00
|
|
|
version = "1.8.0";
|
2018-09-04 10:37:54 +01:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-11-28 22:26:11 +00:00
|
|
|
name = "apache-mxnet-src-${version}-incubating.tar.gz";
|
|
|
|
url = "https://dlcdn.apache.org/incubator/mxnet/${version}/apache-mxnet-src-${version}-incubating.tar.gz";
|
|
|
|
hash = "sha256-la/5hYlaukCcCNVRRRCuOLiEkM+2KBqzpf8PWCbI21Q=";
|
2017-09-16 02:39:25 +01:00
|
|
|
};
|
|
|
|
|
2021-11-28 03:11:09 +00:00
|
|
|
patches = [
|
|
|
|
# Fix build error https://github.com/apache/incubator-mxnet/issues/19405
|
|
|
|
(fetchpatch {
|
|
|
|
name = "mxnet-fix-gcc-linker-error-1.patch";
|
|
|
|
url = "https://github.com/apache/incubator-mxnet/commit/78e31d66d19e385ca4ef73245ce79a47e375d8d1.diff";
|
|
|
|
sha256 = "sha256-UfmGhh4RbvrEOXe6IJxHm1Aqpy1gS6gHxrX5KQBXjv4=";
|
|
|
|
})
|
|
|
|
(fetchpatch {
|
|
|
|
name = "mxnet-fix-gcc-linker-error-2.patch";
|
|
|
|
url = "https://github.com/apache/incubator-mxnet/commit/9bfe3116aabd01049fdbd90855cb245a30b795df.diff";
|
|
|
|
sha256 = "sha256-BL7Zf7Bgn0qpai9HbQ6LBxZNa3iLjVJSe5nxZgqI/fw=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2018-09-04 10:37:54 +01:00
|
|
|
nativeBuildInputs = [ cmake perl ];
|
2017-09-16 02:39:25 +01:00
|
|
|
|
2020-05-06 18:23:32 +01:00
|
|
|
buildInputs = [ opencv3 gtest blas.provider ]
|
2021-11-28 03:11:09 +00:00
|
|
|
++ lib.optional stdenv.cc.isGNU gomp
|
|
|
|
++ lib.optional stdenv.cc.isClang llvmPackages.openmp
|
|
|
|
++ lib.optionals cudaSupport [ cudatoolkit nvidia_x11 ]
|
|
|
|
++ lib.optional cudnnSupport cudnn;
|
2017-09-16 02:39:25 +01:00
|
|
|
|
2018-02-25 17:02:20 +00:00
|
|
|
cmakeFlags =
|
2019-06-02 18:11:58 +01:00
|
|
|
[ "-DUSE_MKL_IF_AVAILABLE=OFF" ]
|
|
|
|
++ (if cudaSupport then [
|
2019-04-12 11:31:22 +01:00
|
|
|
"-DUSE_OLDCMAKECUDA=ON" # see https://github.com/apache/incubator-mxnet/issues/10743
|
2018-02-25 17:02:20 +00:00
|
|
|
"-DCUDA_ARCH_NAME=All"
|
|
|
|
"-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
|
|
|
|
] else [ "-DUSE_CUDA=OFF" ])
|
|
|
|
++ lib.optional (!cudnnSupport) "-DUSE_CUDNN=OFF";
|
2017-09-16 02:39:25 +01:00
|
|
|
|
2018-09-04 10:37:54 +01:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace 3rdparty/mkldnn/tests/CMakeLists.txt \
|
|
|
|
--replace "/bin/bash" "${bash}/bin/bash"
|
2018-09-04 19:27:25 +01:00
|
|
|
|
2020-03-31 15:47:18 +01:00
|
|
|
# Build against the system version of OpenMP.
|
2018-09-04 19:27:25 +01:00
|
|
|
# https://github.com/apache/incubator-mxnet/pull/12160
|
|
|
|
rm -rf 3rdparty/openmp
|
2018-09-04 10:37:54 +01:00
|
|
|
'';
|
|
|
|
|
2018-09-04 19:27:25 +01:00
|
|
|
postInstall = ''
|
|
|
|
rm "$out"/lib/*.a
|
2017-09-16 02:39:25 +01:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-09-16 02:39:25 +01:00
|
|
|
description = "Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "https://mxnet.incubator.apache.org/";
|
2017-09-16 02:39:25 +01:00
|
|
|
maintainers = with maintainers; [ abbradar ];
|
|
|
|
license = licenses.asl20;
|
2021-11-28 03:11:09 +00:00
|
|
|
platforms = platforms.unix;
|
2017-09-16 02:39:25 +01:00
|
|
|
};
|
|
|
|
}
|