2021-12-19 01:06:50 +00:00
|
|
|
{ config, stdenv, lib, fetchurl, fetchpatch, bash, cmake
|
|
|
|
, opencv3, gtest, blas, gomp, llvmPackages, perl
|
2022-04-15 01:41:22 +00:00
|
|
|
, cudaSupport ? config.cudaSupport or false, cudaPackages ? {}, nvidia_x11
|
|
|
|
, cudnnSupport ? cudaSupport
|
|
|
|
, cudaCapabilities ? [ "3.7" "5.0" "6.0" "7.0" "7.5" "8.0" "8.6" ]
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
let
|
|
|
|
inherit (cudaPackages) cudatoolkit cudnn;
|
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mxnet";
|
2021-12-19 01:06:50 +00:00
|
|
|
version = "1.8.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-12-19 01:06:50 +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=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +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=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ cmake perl ];
|
|
|
|
|
2020-06-18 07:06:33 +00:00
|
|
|
buildInputs = [ opencv3 gtest blas.provider ]
|
2021-12-19 01:06:50 +00:00
|
|
|
++ lib.optional stdenv.cc.isGNU gomp
|
|
|
|
++ lib.optional stdenv.cc.isClang llvmPackages.openmp
|
2022-05-18 14:49:53 +00:00
|
|
|
# FIXME: when cuda build is fixed, remove nvidia_x11, and use /run/opengl-driver/lib
|
2021-12-19 01:06:50 +00:00
|
|
|
++ lib.optionals cudaSupport [ cudatoolkit nvidia_x11 ]
|
|
|
|
++ lib.optional cudnnSupport cudnn;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
cmakeFlags =
|
|
|
|
[ "-DUSE_MKL_IF_AVAILABLE=OFF" ]
|
|
|
|
++ (if cudaSupport then [
|
|
|
|
"-DUSE_OLDCMAKECUDA=ON" # see https://github.com/apache/incubator-mxnet/issues/10743
|
|
|
|
"-DCUDA_ARCH_NAME=All"
|
|
|
|
"-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc"
|
2022-04-15 01:41:22 +00:00
|
|
|
"-DMXNET_CUDA_ARCH=${lib.concatStringsSep ";" cudaCapabilities}"
|
2020-04-24 23:36:52 +00:00
|
|
|
] else [ "-DUSE_CUDA=OFF" ])
|
|
|
|
++ lib.optional (!cudnnSupport) "-DUSE_CUDNN=OFF";
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace 3rdparty/mkldnn/tests/CMakeLists.txt \
|
|
|
|
--replace "/bin/bash" "${bash}/bin/bash"
|
|
|
|
|
|
|
|
# Build against the system version of OpenMP.
|
|
|
|
# https://github.com/apache/incubator-mxnet/pull/12160
|
|
|
|
rm -rf 3rdparty/openmp
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
rm "$out"/lib/*.a
|
|
|
|
'';
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
# used to mark cudaSupport in python310Packages.mxnet as broken;
|
|
|
|
# other attributes exposed for consistency
|
|
|
|
passthru = {
|
|
|
|
inherit cudaSupport cudnnSupport cudatoolkit cudnn;
|
|
|
|
};
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Lightweight, Portable, Flexible Distributed/Mobile Deep Learning with Dynamic, Mutation-aware Dataflow Dep Scheduler";
|
|
|
|
homepage = "https://mxnet.incubator.apache.org/";
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
|
|
|
license = licenses.asl20;
|
2021-12-19 01:06:50 +00:00
|
|
|
platforms = platforms.unix;
|
2022-05-18 14:49:53 +00:00
|
|
|
# Build failures when linking mxnet_unit_tests: https://gist.github.com/6d17447ee3557967ec52c50d93b17a1d
|
|
|
|
broken = cudaSupport;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|