@@ -1,151 +0,0 @@
1−{ stdenv, lib, config, fetchFromGitHub
2−, cmake
3−, glog, gflags, gtest
4−, protobuf, snappy
5−, python, future, six, python-protobuf, numpy, pydot
6−, eigen
7−, doxygen
8−, useCuda ? (config.cudaSupport or false), cudaPackages ? {}
9−, useCudnn ? (config.cudnnSupport or false)
10−, useOpenmp ? false, openmp ? null
11−, useOpencv3 ? true, opencv3 ? null
12−, useLeveldb ? false, leveldb ? null
13−, useLmdb ? true, lmdb ? null
14−, useRocksdb ? false, rocksdb ? null
15−, useZeromq ? false, zeromq ? null
16−, useMpi ? false, mpi ? null
17−# TODO: distributed computations
18−#, useGloo ? false
19−#, useNccl ? false
20−#, useNnpack ? false
21−}:
22−
23−let
24− inherit (cudaPackages) cudatoolkit cudnn;
25−in
26−
27−assert useCuda -> cudatoolkit != null;
28−assert useCudnn -> (useCuda && cudnn != null);
29−assert useOpencv3 -> opencv3 != null;
30−assert useLeveldb -> leveldb != null;
31−assert useLmdb -> lmdb != null;
32−assert useRocksdb -> rocksdb != null;
33−assert useZeromq -> zeromq != null;
34−assert useMpi -> mpi != null;
35−
36−let
37− # Third party modules that caffe2 holds as git submodules.
38− # Download them and create symlinks from caffe2/third_party.
39− installExtraSrc = extra: ''
40− rmdir "third_party/${extra.dst}"
41− ln -s "${extra.src}" "third_party/${extra.dst}"
42− '';
43−
44− cub = {
45− src = fetchFromGitHub {
46− owner = "NVlabs";
47− repo = "cub";
48− rev = "v1.7.4";
49− sha256 = "0ksd5n1lxqhm5l5cd2lps4cszhjkf6gmzahaycs7nxb06qci8c66";
50− };
51− dst = "cub";
52− };
53−
54− pybind11 = {
55− src = fetchFromGitHub {
56− owner = "pybind";
57− repo = "pybind11";
58− rev = "86e2ad4f77442c3350f9a2476650da6bee253c52";
59− sha256 = "05gi58dirvc8fgm0avpydvidzsbh2zrzgfaq671ym09f6dz0bcgz";
60− };
61− dst = "pybind11";
62− };
63−
64− ccVersion = lib.getVersion stdenv.cc;
65−in
66−
67−stdenv.mkDerivation rec {
68− pname = "caffe2";
69− version = "0.8.1";
70− src = fetchFromGitHub {
71− owner = "caffe2";
72− repo = "caffe2";
73− rev = "v${version}";
74− sha256 = "18y7zjc69j6n5642l9caddl641b0djf3pjn4wacdsc1wk1jiyqk8";
75− };
76−
77− nativeBuildInputs = [ cmake doxygen gtest ];
78− outputs = [ "bin" "out" ];
79− propagatedBuildOutputs = [ ]; # otherwise propagates out -> bin cycle
80−
81− buildInputs = [ glog gflags protobuf snappy eigen ]
82− ++ lib.optional useCuda cudatoolkit
83− ++ lib.optional useCudnn cudnn
84− ++ lib.optional useOpenmp openmp
85− ++ lib.optional useOpencv3 opencv3
86− ++ lib.optional useLeveldb leveldb
87− ++ lib.optional useLmdb lmdb
88− ++ lib.optional useRocksdb rocksdb
89− ++ lib.optional useZeromq zeromq
90− ;
91− propagatedBuildInputs = [ numpy future six python-protobuf pydot ];
92−
93− patches = lib.optional (stdenv.cc.isGNU && lib.versionAtLeast ccVersion "7.0.0") [
94− ./fix_compilation_on_gcc7.patch
95− ] ++ lib.optional stdenv.cc.isClang [ ./update_clang_cvtsh_bugfix.patch ];
96−
97− cmakeFlags = [ "-DBUILD_TEST=OFF"
98− "-DBUILD_PYTHON=ON"
99− ''-DUSE_CUDA=${if useCuda then "ON"else "OFF"}''
100− ''-DUSE_OPENMP=${if useOpenmp then "ON"else "OFF"}''
101− ''-DUSE_OPENCV=${if useOpencv3 then "ON"else "OFF"}''
102− ''-DUSE_MPI=${if useMpi then "ON"else "OFF"}''
103− ''-DUSE_LEVELDB=${if useLeveldb then "ON"else "OFF"}''
104− ''-DUSE_LMDB=${if useLmdb then "ON"else "OFF"}''
105− ''-DUSE_ROCKSDB=${if useRocksdb then "ON"else "OFF"}''
106− ''-DUSE_ZMQ=${if useZeromq then "ON"else "OFF"}''
107− "-DUSE_GLOO=OFF"
108− "-DUSE_NNPACK=OFF"
109− "-DUSE_NCCL=OFF"
110− "-DUSE_REDIS=OFF"
111− "-DUSE_FFMPEG=OFF"
112− ]
113− ++ lib.optional useCuda [
114− "-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit}"
115− "-DCUDA_FAST_MATH=ON"
116− "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/gcc"
117− ];
118−
119− preConfigure = ''
120− ${installExtraSrc cub}
121− ${installExtraSrc pybind11}
122− # XXX hack
123− export NIX_CFLAGS_COMPILE="-I ${eigen}/include/eigen3/ $NIX_CFLAGS_COMPILE"
124− '';
125−
126− postInstall = ''
127− moveToOutput "bin" "$bin"
128− mkdir -p $out/lib/${python.libPrefix}
129− ln -s $out/ $out/${python.sitePackages}
130− '';
131−
132− doCheck = false;
133−
134− meta = {
135− homepage = "https://caffe2.ai/";
136− description = "A new lightweight, modular, and scalable deep learning framework";
137− longDescription = ''
138− Caffe2 aims to provide an easy and straightforward way for you to experiment
139− with deep learning and leverage community contributions of new models and
140− algorithms. You can bring your creations to scale using the power of GPUs in the
141− cloud or to the masses on mobile with Caffe2's cross-platform libraries.
142− '';
143− platforms = with lib.platforms; linux;
144− license = lib.licenses.asl20;
145− maintainers = with lib.maintainers; [ yuriaisaka ];
146− # fails to compile with
147− # error: invalid conversion from 'const char*' to 'char*'
148− # TODO: Remove usage of python2, protobuf overwrite
149− broken = true;
150− };
151−}