2021-12-19 01:06:50 +00:00
|
|
|
{ config, stdenv, lib, fetchurl, fetchpatch, bash, cmake
|
|
|
|
, opencv3, gtest, blas, gomp, llvmPackages, perl
|
2023-08-04 22:07:22 +00:00
|
|
|
, cudaSupport ? config.cudaSupport, cudaPackages ? { }, nvidia_x11
|
2022-04-15 01:41:22 +00:00
|
|
|
, cudnnSupport ? cudaSupport
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
let
|
2022-12-17 10:02:37 +00:00
|
|
|
inherit (cudaPackages) cudatoolkit cudaFlags cudnn;
|
2022-04-15 01:41:22 +00:00
|
|
|
in
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mxnet";
|
2022-09-30 11:47:45 +00:00
|
|
|
version = "1.9.1";
|
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";
|
2022-09-30 11:47:45 +00:00
|
|
|
hash = "sha256-EephMoF02MKblvNBl34D3rC/Sww3rOZY+T442euMkyI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
patches = [
|
2022-09-30 11:47:45 +00:00
|
|
|
# Remove the following two patches when updating mxnet to 2.0.
|
2021-12-19 01:06:50 +00:00
|
|
|
(fetchpatch {
|
2022-09-30 11:47:45 +00:00
|
|
|
name = "1-auto-disable-sse-for-non-x86.patch";
|
|
|
|
url = "https://github.com/apache/incubator-mxnet/commit/55e69871d4cadec51a8bbb6700131065388cb0b9.patch";
|
|
|
|
hash = "sha256-uaMpM0F9HRtEBXz2ewB/dlbuKaY5/RineCPUE2T6CHU=";
|
2021-12-19 01:06:50 +00:00
|
|
|
})
|
|
|
|
(fetchpatch {
|
2022-09-30 11:47:45 +00:00
|
|
|
name = "2-auto-disable-sse-for-non-x86.patch";
|
|
|
|
url = "https://github.com/apache/incubator-mxnet/commit/c1b96f562f55dfa024ac941d7b104f00e239ee0f.patch";
|
|
|
|
excludes = ["ci/docker/runtime_functions.sh"];
|
|
|
|
hash = "sha256-r1LbC8ueRooW5tTNakAlRSJ+9aR4WXXoEKx895DgOs4=";
|
2021-12-19 01:06:50 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
|
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"
|
2023-03-08 16:32:21 +00:00
|
|
|
"-DMXNET_CUDA_ARCH=${builtins.concatStringsSep ";" cudaFlags.realArches}"
|
2020-04-24 23:36:52 +00:00
|
|
|
] else [ "-DUSE_CUDA=OFF" ])
|
|
|
|
++ lib.optional (!cudnnSupport) "-DUSE_CUDNN=OFF";
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [
|
2023-02-16 17:41:37 +00:00
|
|
|
# Needed with GCC 12
|
|
|
|
"-Wno-error=uninitialized"
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|