python3Packages.torchvision: added cudaSupport option (#132917)

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

authored by

Alexander Kiselyov
Sandro
and committed by
GitHub
717538e9 0d078fcd

+26 -3
+5
pkgs/development/python-modules/pytorch/default.nix
··· 301 # Builds in 2+h with 2 cores, and ~15m with a big-parallel builder. 302 requiredSystemFeatures = [ "big-parallel" ]; 303 304 meta = with lib; { 305 description = "Open source, prototype-to-production deep learning platform"; 306 homepage = "https://pytorch.org/";
··· 301 # Builds in 2+h with 2 cores, and ~15m with a big-parallel builder. 302 requiredSystemFeatures = [ "big-parallel" ]; 303 304 + passthru = { 305 + inherit cudaSupport; 306 + cudaArchList = final_cudaArchList; 307 + }; 308 + 309 meta = with lib; { 310 description = "Open source, prototype-to-production deep learning platform"; 311 homepage = "https://pytorch.org/";
+21 -3
pkgs/development/python-modules/torchvision/default.nix
··· 1 { lib 2 , buildPythonPackage 3 , fetchFromGitHub 4 , ninja ··· 10 , pillow 11 , pytorch 12 , pytest 13 }: 14 15 - buildPythonPackage rec { 16 pname = "torchvision"; 17 version = "0.10.0"; 18 ··· 23 sha256 = "13j04ij0jmi58nhav1p69xrm8dg7jisg23268i3n6lnms37n02kc"; 24 }; 25 26 - nativeBuildInputs = [ libpng ninja which ]; 27 28 TORCHVISION_INCLUDE = "${libjpeg_turbo.dev}/include/"; 29 TORCHVISION_LIBRARY = "${libjpeg_turbo}/lib/"; 30 31 - buildInputs = [ libjpeg_turbo libpng ]; 32 33 propagatedBuildInputs = [ numpy pillow pytorch scipy ]; 34 35 # tries to download many datasets for tests 36 doCheck = false; 37 ··· 45 description = "PyTorch vision library"; 46 homepage = "https://pytorch.org/"; 47 license = licenses.bsd3; 48 maintainers = with maintainers; [ ericsagnes ]; 49 }; 50 }
··· 1 { lib 2 + , symlinkJoin 3 , buildPythonPackage 4 , fetchFromGitHub 5 , ninja ··· 11 , pillow 12 , pytorch 13 , pytest 14 + , cudatoolkit 15 + , cudnn 16 + , cudaSupport ? pytorch.cudaSupport or false # by default uses the value from pytorch 17 }: 18 19 + let 20 + cudatoolkit_joined = symlinkJoin { 21 + name = "${cudatoolkit.name}-unsplit"; 22 + paths = [ cudatoolkit.out cudatoolkit.lib ]; 23 + }; 24 + cudaArchStr = lib.optionalString cudaSupport lib.strings.concatStringsSep ";" pytorch.cudaArchList; 25 + in buildPythonPackage rec { 26 pname = "torchvision"; 27 version = "0.10.0"; 28 ··· 33 sha256 = "13j04ij0jmi58nhav1p69xrm8dg7jisg23268i3n6lnms37n02kc"; 34 }; 35 36 + nativeBuildInputs = [ libpng ninja which ] 37 + ++ lib.optionals cudaSupport [ cudatoolkit_joined ]; 38 39 TORCHVISION_INCLUDE = "${libjpeg_turbo.dev}/include/"; 40 TORCHVISION_LIBRARY = "${libjpeg_turbo}/lib/"; 41 42 + buildInputs = [ libjpeg_turbo libpng ] 43 + ++ lib.optionals cudaSupport [ cudnn ]; 44 45 propagatedBuildInputs = [ numpy pillow pytorch scipy ]; 46 47 + preBuild = lib.optionalString cudaSupport '' 48 + export TORCH_CUDA_ARCH_LIST="${cudaArchStr}" 49 + export FORCE_CUDA=1 50 + ''; 51 + 52 # tries to download many datasets for tests 53 doCheck = false; 54 ··· 62 description = "PyTorch vision library"; 63 homepage = "https://pytorch.org/"; 64 license = licenses.bsd3; 65 + platforms = with platforms; linux ++ lib.optionals (!cudaSupport) darwin; 66 maintainers = with maintainers; [ ericsagnes ]; 67 }; 68 }