2017-09-03 13:15:39 +00:00
|
|
|
{ stdenv, lib
|
2015-07-04 23:42:54 +00:00
|
|
|
, fetchFromGitHub
|
2017-09-03 13:15:39 +00:00
|
|
|
, cmake
|
|
|
|
, boost
|
2015-07-04 23:42:54 +00:00
|
|
|
, google-gflags
|
|
|
|
, glog
|
2017-09-03 13:15:39 +00:00
|
|
|
, hdf5-cpp
|
2015-07-04 23:42:54 +00:00
|
|
|
, leveldb
|
|
|
|
, lmdb
|
|
|
|
, opencv
|
|
|
|
, protobuf
|
|
|
|
, snappy
|
2017-09-03 13:15:39 +00:00
|
|
|
, atlas
|
|
|
|
, doxygen
|
|
|
|
, cudaSupport ? true, cudatoolkit
|
|
|
|
, cudnnSupport ? false, cudnn ? null
|
|
|
|
, pythonSupport ? false, python ? null, numpy ? null
|
2015-07-04 23:42:54 +00:00
|
|
|
}:
|
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
assert cudnnSupport -> cudaSupport;
|
|
|
|
assert pythonSupport -> (python != null && numpy != null);
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2017-09-03 11:55:57 +00:00
|
|
|
name = "caffe-${version}";
|
|
|
|
version = "1.0-rc5";
|
2015-07-04 23:42:54 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "BVLC";
|
|
|
|
repo = "caffe";
|
2017-09-03 11:55:57 +00:00
|
|
|
rev = "rc5";
|
|
|
|
sha256 = "0lfmmc0n6xvkpygvxclzrvd0zigb4yfc5612anv2ahlxpfi9031c";
|
2015-07-04 23:42:54 +00:00
|
|
|
};
|
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
enableParallelBuilding = true;
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
nativeBuildInputs = [ cmake doxygen ];
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
cmakeFlags = [ "-DCUDA_ARCH_NAME=All" ]
|
|
|
|
++ lib.optional (!cudaSupport) "-DCPU_ONLY=ON"
|
|
|
|
++ lib.optional (!pythonSupport) "-DBUILD_python=OFF";
|
2017-09-03 11:55:57 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
buildInputs = [ boost google-gflags glog protobuf hdf5-cpp lmdb leveldb snappy opencv atlas ]
|
|
|
|
++ lib.optional cudaSupport cudatoolkit
|
|
|
|
++ lib.optional cudnnSupport cudnn
|
|
|
|
++ lib.optionals pythonSupport [ python numpy ];
|
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optional pythonSupport python.pkgs.protobuf;
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
outputs = [ "out" "bin" ];
|
|
|
|
# Don't propagate bin.
|
|
|
|
outputBin = "out";
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
postInstall = ''
|
|
|
|
# Internal static library.
|
|
|
|
rm $out/lib/libproto.a
|
2015-07-04 23:42:54 +00:00
|
|
|
|
2017-09-03 13:15:39 +00:00
|
|
|
moveToOutput "bin" "$bin"
|
|
|
|
'' + lib.optionalString pythonSupport ''
|
|
|
|
mkdir -p $out/${python.sitePackages}
|
|
|
|
mv $out/python/caffe $out/${python.sitePackages}
|
|
|
|
rm -rf $out/python
|
2015-07-04 23:42:54 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Deep learning framework";
|
|
|
|
longDescription = ''
|
|
|
|
Caffe is a deep learning framework made with expression, speed, and
|
|
|
|
modularity in mind. It is developed by the Berkeley Vision and Learning
|
|
|
|
Center (BVLC) and by community contributors.
|
|
|
|
'';
|
|
|
|
homepage = http://caffe.berkeleyvision.org/;
|
|
|
|
maintainers = with maintainers; [ jb55 ];
|
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|