Skip to content

Commit 855a7ba

Browse files
author
Connor Baker
committed
caffe: fix eval when CUDNN is not available
1 parent ec1bb84 commit 855a7ba

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

pkgs/applications/science/math/caffe/default.nix

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,17 @@ let
2626
# The default for cudatoolkit 10.1 is CUDNN 8.0.5, the last version to support CUDA 10.1.
2727
# However, this caffe does not build with CUDNN 8.x, so we use CUDNN 7.6.5 instead.
2828
# Earlier versions of cudatoolkit use pre-8.x CUDNN, so we use the default.
29-
cudnn = if lib.versionOlder cudatoolkit.version "10.1"
30-
then cudaPackages.cudnn
31-
else cudaPackages.cudnn_7_6;
32-
in
33-
34-
assert leveldbSupport -> (leveldb != null && snappy != null);
35-
assert cudnnSupport -> cudaSupport;
36-
assert ncclSupport -> cudaSupport;
37-
assert pythonSupport -> (python != null && numpy != null);
29+
hasCudnn =
30+
if lib.versionOlder cudatoolkit.version "10.1"
31+
then cudaPackages ? cudnn
32+
else cudaPackages ? cudnn_7_6;
3833

39-
let
4034
toggle = bool: if bool then "ON" else "OFF";
4135

4236
test_model_weights = fetchurl {
4337
url = "http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel";
4438
sha256 = "472d4a06035497b180636d8a82667129960371375bd10fcb6df5c6c7631f25e0";
4539
};
46-
4740
in
4841

4942
stdenv.mkDerivation rec {
@@ -74,7 +67,8 @@ stdenv.mkDerivation rec {
7467

7568
buildInputs = [ boost gflags glog protobuf hdf5-cpp opencv4 blas ]
7669
++ lib.optional cudaSupport cudatoolkit
77-
++ lib.optional cudnnSupport cudnn
70+
++ lib.optional (lib.versionOlder cudatoolkit.version "10.1" && hasCudnn) cudaPackages.cudnn
71+
++ lib.optional (lib.versionAtLeast cudatoolkit.version "10.1" && hasCudnn) cudaPackages.cudnn_7_6
7872
++ lib.optional lmdbSupport lmdb
7973
++ lib.optional ncclSupport nccl
8074
++ lib.optionals leveldbSupport [ leveldb snappy ]
@@ -154,7 +148,14 @@ stdenv.mkDerivation rec {
154148
'';
155149
homepage = "http://caffe.berkeleyvision.org/";
156150
maintainers = with maintainers; [ ];
157-
broken = (pythonSupport && (python.isPy310)) || cudaSupport;
151+
broken =
152+
(pythonSupport && (python.isPy310))
153+
|| cudaSupport
154+
|| !(leveldbSupport -> (leveldb != null && snappy != null))
155+
|| !(cudnnSupport -> (hasCudnn && cudaSupport))
156+
|| !(ncclSupport -> cudaSupport)
157+
|| !(pythonSupport -> (python != null && numpy != null))
158+
;
158159
license = licenses.bsd2;
159160
platforms = platforms.linux ++ platforms.darwin;
160161
};

0 commit comments

Comments
 (0)