2024-01-02 11:29:13 +00:00
{ stdenv
, lib
, fetchFromGitHub
, cmake
, pkg-config
, libpng
, libjpeg
, libwebp
2024-01-25 14:12:00 +00:00
, blas
, lapack
, config
2024-01-02 11:29:13 +00:00
, guiSupport ? false
, libX11
2024-06-20 14:57:18 +00:00
, enableShared ? ! stdenv . hostPlatform . isStatic # dlib has a build system that forces the user to choose between either shared or static libraries. See https://github.com/davisking/dlib/issues/923#issuecomment-2175865174
2021-03-09 03:18:52 +00:00
, sse4Support ? stdenv . hostPlatform . sse4_1Support
2020-09-25 04:45:31 +00:00
, avxSupport ? stdenv . hostPlatform . avxSupport
2024-01-25 14:12:00 +00:00
, cudaSupport ? config . cudaSupport
, cudaPackages
} @ inputs :
( if cudaSupport then cudaPackages . backendStdenv else inputs . stdenv ) . mkDerivation rec {
2020-04-24 23:36:52 +00:00
pname = " d l i b " ;
2024-06-20 14:57:18 +00:00
version = " 1 9 . 2 4 . 4 " ;
2020-04-24 23:36:52 +00:00
src = fetchFromGitHub {
owner = " d a v i s k i n g " ;
repo = " d l i b " ;
2024-01-25 14:12:00 +00:00
rev = " v ${ version } " ;
2024-06-20 14:57:18 +00:00
sha256 = " s h a 2 5 6 - 1 A / 9 u + T h t U t m m S w n F S n 8 S 6 5 Y a v u c l 2 X + o 3 b N Y g e w 0 O c = " ;
2020-04-24 23:36:52 +00:00
} ;
postPatch = ''
rm - rf dlib/external
'' ;
2020-09-25 04:45:31 +00:00
cmakeFlags = [
2024-06-20 14:57:18 +00:00
( lib . cmakeBool " B U I L D _ S H A R E D _ L I B S " enableShared )
2024-01-02 11:29:13 +00:00
( lib . cmakeBool " U S E _ S S E 4 _ I N S T R U C T I O N S " sse4Support )
( lib . cmakeBool " U S E _ A V X _ I N S T R U C T I O N S " avxSupport )
2024-01-25 14:12:00 +00:00
( lib . cmakeBool " D L I B _ U S E _ C U D A " cudaSupport )
] ++ lib . optionals cudaSupport [
( lib . cmakeFeature " D L I B _ U S E _ C U D A _ C O M P U T E _ C A P A B I L I T I E S " ( builtins . concatStringsSep " , " ( with cudaPackages . flags ; map dropDot cudaCapabilities ) ) )
2024-01-02 11:29:13 +00:00
] ;
2020-04-24 23:36:52 +00:00
2024-01-25 14:12:00 +00:00
nativeBuildInputs = [
cmake
pkg-config
] ++ lib . optionals cudaSupport ( with cudaPackages ; [
cuda_nvcc
] ) ;
2024-01-02 11:29:13 +00:00
buildInputs = [
libpng
libjpeg
libwebp
2024-01-25 14:12:00 +00:00
blas
lapack
]
++ lib . optionals guiSupport [ libX11 ]
2024-04-21 15:54:59 +00:00
++ lib . optionals cudaSupport ( with cudaPackages ; [
2024-01-25 14:12:00 +00:00
cuda_cudart . dev
cuda_cudart . lib
cuda_cudart . static
cuda_nvcc . dev
libcublas . dev
libcublas . lib
libcublas . static
libcurand . dev
libcurand . lib
libcurand . static
libcusolver . dev
libcusolver . lib
libcusolver . static
cudnn . dev
cudnn . lib
cudnn . static
cuda_cccl . dev
] ) ;
passthru = {
inherit
cudaSupport cudaPackages
sse4Support avxSupport ;
} ;
2020-04-24 23:36:52 +00:00
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2024-06-20 14:57:18 +00:00
description = " G e n e r a l p u r p o s e c r o s s - p l a t f o r m C + + m a c h i n e l e a r n i n g l i b r a r y " ;
2020-04-24 23:36:52 +00:00
homepage = " h t t p : / / w w w . d l i b . n e t " ;
license = licenses . boost ;
2023-10-19 13:55:26 +00:00
maintainers = with maintainers ; [ christopherpoole ] ;
2022-09-09 14:08:57 +00:00
platforms = platforms . unix ;
2020-04-24 23:36:52 +00:00
} ;
}