2017-10-15 23:56:43 +02:00
|
|
|
{ lib, stdenv, fetchgit, fetchFromGitHub, fetchpatch, cmake
|
|
|
|
, openblas, opencv3, libzip, boost, protobuf, openmpi
|
|
|
|
, onebitSGDSupport ? false
|
|
|
|
, cudaSupport ? false, cudatoolkit, nvidia_x11
|
|
|
|
, cudnnSupport ? false, cudnn
|
|
|
|
}:
|
|
|
|
|
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
|
|
|
|
let
|
|
|
|
# Old specific version required for CNTK.
|
|
|
|
cub = fetchFromGitHub {
|
|
|
|
owner = "NVlabs";
|
|
|
|
repo = "cub";
|
2018-02-25 17:58:21 +01:00
|
|
|
rev = "1.7.4";
|
|
|
|
sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
|
2017-10-15 23:56:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
in stdenv.mkDerivation rec {
|
|
|
|
name = "CNTK-${version}";
|
2018-02-25 17:58:21 +01:00
|
|
|
version = "2.4";
|
2017-10-15 23:56:43 +02:00
|
|
|
|
|
|
|
# Submodules
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://github.com/Microsoft/CNTK";
|
|
|
|
rev = "v${version}";
|
2018-02-25 17:58:21 +01:00
|
|
|
sha256 = "0m28wb0ljixcpi14g3gcfiraimh487yxqhd9yrglgyvjb69x597y";
|
2017-10-15 23:56:43 +02:00
|
|
|
};
|
|
|
|
|
2018-02-25 17:58:21 +01:00
|
|
|
patches = [ ./fix_std_bind.patch ];
|
2017-10-15 23:56:43 +02:00
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ];
|
|
|
|
|
|
|
|
buildInputs = [ openblas opencv3 libzip boost protobuf openmpi ]
|
|
|
|
++ lib.optional cudaSupport cudatoolkit
|
|
|
|
++ lib.optional cudnnSupport cudnn;
|
|
|
|
|
|
|
|
configureFlags = [
|
|
|
|
"--with-opencv=${opencv3}"
|
|
|
|
"--with-libzip=${libzip.dev}"
|
|
|
|
"--with-openblas=${openblas}"
|
|
|
|
"--with-boost=${boost.dev}"
|
|
|
|
"--with-protobuf=${protobuf}"
|
|
|
|
"--with-mpi=${openmpi}"
|
2018-02-25 20:49:59 +01:00
|
|
|
"--cuda=${if cudaSupport then "yes" else "no"}"
|
2018-02-25 17:58:21 +01:00
|
|
|
# FIXME
|
|
|
|
"--asgd=no"
|
2018-02-25 20:49:59 +01:00
|
|
|
] ++ lib.optionals cudaSupport [
|
2017-10-15 23:56:43 +02:00
|
|
|
"--with-cuda=${cudatoolkit}"
|
|
|
|
"--with-gdk-include=${cudatoolkit}/include"
|
|
|
|
"--with-gdk-nvml-lib=${nvidia_x11}/lib"
|
|
|
|
"--with-cub=${cub}"
|
|
|
|
] ++ lib.optional onebitSGDSupport "--1bitsgd=yes";
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
sed -i \
|
|
|
|
-e 's,^GIT_STATUS=.*,GIT_STATUS=,' \
|
|
|
|
-e 's,^GIT_COMMIT=.*,GIT_COMMIT=v${version},' \
|
|
|
|
-e 's,^GIT_BRANCH=.*,GIT_BRANCH=v${version},' \
|
|
|
|
-e 's,^BUILDER=.*,BUILDER=nixbld,' \
|
|
|
|
-e 's,^BUILDMACHINE=.*,BUILDMACHINE=machine,' \
|
|
|
|
-e 's,^BUILDPATH=.*,BUILDPATH=/homeless-shelter,' \
|
|
|
|
-e '/git does not exist/d' \
|
|
|
|
Tools/generate_build_info
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
mkdir build
|
|
|
|
cd build
|
|
|
|
${lib.optionalString cudnnSupport ''
|
|
|
|
mkdir cuda
|
|
|
|
ln -s ${cudnn}/include cuda
|
|
|
|
export configureFlags="$configureFlags --with-cudnn=$PWD"
|
|
|
|
''}
|
|
|
|
../configure $configureFlags
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
# Moving to make patchelf remove references later.
|
|
|
|
mv lib $out
|
|
|
|
cp bin/cntk $out/bin
|
|
|
|
'';
|
|
|
|
|
2018-02-25 17:58:21 +01:00
|
|
|
enableParallelBuilding = true;
|
2017-10-15 23:56:43 +02:00
|
|
|
|
|
|
|
meta = with lib; {
|
2018-02-25 17:47:45 +01:00
|
|
|
homepage = https://github.com/Microsoft/CNTK;
|
2017-10-15 23:56:43 +02:00
|
|
|
description = "An open source deep-learning toolkit";
|
|
|
|
license = if onebitSGDSupport then licenses.unfreeRedistributable else licenses.mit;
|
|
|
|
maintainers = with maintainers; [ abbradar ];
|
|
|
|
};
|
|
|
|
}
|