From 25079ad238144950fc846eaf90b77439844d0832 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 25 Feb 2018 20:00:26 +0300 Subject: [PATCH] caffe: depend on opencv3 openblas is used since it's propagated from OpenCV and ATLAS compiled without architecture-specific optimizations is generally slower than OpenBLAS as I heard. --- .../applications/science/math/caffe/default.nix | 17 ++++++++++------- pkgs/top-level/all-packages.nix | 4 ++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/science/math/caffe/default.nix b/pkgs/applications/science/math/caffe/default.nix index 8dc3e3ce43dc..dc9c5f7359ec 100644 --- a/pkgs/applications/science/math/caffe/default.nix +++ b/pkgs/applications/science/math/caffe/default.nix @@ -7,11 +7,11 @@ , hdf5-cpp , leveldb , lmdb -, opencv +, opencv3 , protobuf , snappy -, atlas , doxygen +, openblas , cudaSupport ? true, cudatoolkit , cudnnSupport ? false, cudnn ? null , pythonSupport ? false, python ? null, numpy ? null @@ -35,12 +35,15 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ cmake doxygen ]; - cmakeFlags = [ - "-DCUDA_ARCH_NAME=All" - (if pythonSupport then "-Dpython_version=${python.version}" else "-DBUILD_python=OFF") - ] ++ lib.optional (!cudaSupport) "-DCPU_ONLY=ON"; + cmakeFlags = + [ (if pythonSupport then "-Dpython_version=${python.version}" else "-DBUILD_python=OFF") + "-DBLAS=open" + ] ++ (if cudaSupport then [ + "-DCUDA_ARCH_NAME=All" + "-DCUDA_HOST_COMPILER=${cudatoolkit.cc}/bin/cc" + ] else [ "-DCPU_ONLY=ON" ]); - buildInputs = [ boost google-gflags glog protobuf hdf5-cpp lmdb leveldb snappy opencv atlas ] + buildInputs = [ boost google-gflags glog protobuf hdf5-cpp lmdb leveldb snappy opencv3 openblas ] ++ lib.optional cudaSupport cudatoolkit ++ lib.optional cudnnSupport cudnn ++ lib.optionals pythonSupport [ python numpy ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 003882e59afe..0f435228978e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -19737,6 +19737,10 @@ with pkgs; caffe = callPackage ../applications/science/math/caffe rec { cudaSupport = config.caffe.cudaSupport or config.cudaSupport or false; cudnnSupport = cudaSupport; + # Used only for image loading. + opencv3 = self.opencv3.override { + enableCuda = false; + }; }; caffe2 = callPackage ../development/libraries/science/math/caffe2 {