Skip to content

Commit

Permalink
Merge pull request #272770 from NixOS/backport-272761-to-release-23.11
Browse files Browse the repository at this point in the history
[Backport release-23.11] caffe: fix eval when CUDNN is not available
  • Loading branch information
Connor Baker authored Dec 7, 2023
2 parents 9677309 + 18ca1c0 commit 6037ea8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions pkgs/applications/science/math/caffe/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,17 @@ let
# The default for cudatoolkit 10.1 is CUDNN 8.0.5, the last version to support CUDA 10.1.
# However, this caffe does not build with CUDNN 8.x, so we use CUDNN 7.6.5 instead.
# Earlier versions of cudatoolkit use pre-8.x CUDNN, so we use the default.
cudnn = if lib.versionOlder cudatoolkit.version "10.1"
then cudaPackages.cudnn
else cudaPackages.cudnn_7_6;
in

assert leveldbSupport -> (leveldb != null && snappy != null);
assert cudnnSupport -> cudaSupport;
assert ncclSupport -> cudaSupport;
assert pythonSupport -> (python != null && numpy != null);
hasCudnn =
if lib.versionOlder cudatoolkit.version "10.1"
then cudaPackages ? cudnn
else cudaPackages ? cudnn_7_6;

let
toggle = bool: if bool then "ON" else "OFF";

test_model_weights = fetchurl {
url = "http://dl.caffe.berkeleyvision.org/bvlc_reference_caffenet.caffemodel";
sha256 = "472d4a06035497b180636d8a82667129960371375bd10fcb6df5c6c7631f25e0";
};

in

stdenv.mkDerivation rec {
Expand Down Expand Up @@ -74,7 +67,8 @@ stdenv.mkDerivation rec {

buildInputs = [ boost gflags glog protobuf hdf5-cpp opencv4 blas ]
++ lib.optional cudaSupport cudatoolkit
++ lib.optional cudnnSupport cudnn
++ lib.optional (lib.versionOlder cudatoolkit.version "10.1" && hasCudnn) cudaPackages.cudnn
++ lib.optional (lib.versionAtLeast cudatoolkit.version "10.1" && hasCudnn) cudaPackages.cudnn_7_6
++ lib.optional lmdbSupport lmdb
++ lib.optional ncclSupport nccl
++ lib.optionals leveldbSupport [ leveldb snappy ]
Expand Down Expand Up @@ -154,7 +148,14 @@ stdenv.mkDerivation rec {
'';
homepage = "http://caffe.berkeleyvision.org/";
maintainers = with maintainers; [ ];
broken = (pythonSupport && (python.isPy310)) || cudaSupport;
broken =
(pythonSupport && (python.isPy310))
|| cudaSupport
|| !(leveldbSupport -> (leveldb != null && snappy != null))
|| !(cudnnSupport -> (hasCudnn && cudaSupport))
|| !(ncclSupport -> cudaSupport)
|| !(pythonSupport -> (python != null && numpy != null))
;
license = licenses.bsd2;
platforms = platforms.linux ++ platforms.darwin;
};
Expand Down

0 comments on commit 6037ea8

Please sign in to comment.