uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead

https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948
this can do it nicely.

Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
Anton Arapov 2021-04-03 12:58:10 +02:00 committed by Alan Daniels
commit 56de2bcd43
30691 changed files with 3076956 additions and 0 deletions

View file

@ -0,0 +1,116 @@
final: prev: let
inherit (final) callPackage;
inherit (prev) cudatoolkit cudaVersion lib pkgs;
### CuDNN
buildCuDnnPackage = args:
let
useCudatoolkitRunfile = lib.versionOlder cudaVersion "11.3.999";
in
callPackage ./generic.nix { inherit useCudatoolkitRunfile; } args;
toUnderscore = str: lib.replaceStrings ["."] ["_"] str;
majorMinorPatch = str: lib.concatStringsSep "." (lib.take 3 (lib.splitVersion str));
cuDnnPackages = with lib; let
# Check whether a file is supported for our cuda version
isSupported = fileData: elem cudaVersion fileData.supportedCudaVersions;
# Return the first file that is supported. In practice there should only ever be one anyway.
supportedFile = files: findFirst isSupported null files;
# Supported versions with versions as keys and file as value
supportedVersions = filterAttrs (version: file: file !=null ) (mapAttrs (version: files: supportedFile files) cuDnnVersions);
# Compute versioned attribute name to be used in this package set
computeName = version: "cudnn_${toUnderscore version}";
# Add all supported builds as attributes
allBuilds = mapAttrs' (version: file: nameValuePair (computeName version) (buildCuDnnPackage (removeAttrs file ["fileVersion"]))) supportedVersions;
# Set the default attributes, e.g. cudnn = cudnn_8_3_1;
defaultBuild = { "cudnn" = allBuilds.${computeName cuDnnDefaultVersion}; };
in allBuilds // defaultBuild;
cuDnnVersions = let
urlPrefix = "https://developer.download.nvidia.com/compute/redist/cudnn";
in {
"7.4.2" = [
rec {
fileVersion = "10.0";
fullVersion = "7.4.2.24";
sha256 = "18ys0apiz9afid2s6lvy9qbyi8g66aimb2a7ikl1f3dm09mciprf";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-10.0-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "10.0" ];
}
];
"7.6.5" = [
rec {
fileVersion = "10.0";
fullVersion = "7.6.5.32";
hash = "sha256-KDVeOV8LK5OsLIO2E2CzW6bNA3fkTni+GXtrYbS0kro=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-${cudatoolkit.majorVersion}-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "10.0" ];
}
rec {
fileVersion = "10.1";
fullVersion = "7.6.5.32";
hash = "sha256-fq7IA5osMKsLx1jTA1iHZ2k972v0myJIWiwAvy4TbLM=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-${cudatoolkit.majorVersion}-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "10.1" ];
}
rec {
fileVersion = "10.2";
fullVersion = "7.6.5.32";
hash = "sha256-fq7IA5osMKsLx1jTA1iHZ2k972v0myJIWiwAvy4TbLN=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-${cudatoolkit.majorVersion}-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "10.2" ];
}
];
"8.1.1" = [
rec {
fileVersion = "10.2";
fullVersion = "8.1.1.33";
hash = "sha256-Kkp7mabpv6aQ6xm7QeSVU/KnpJGls6v8rpAOFmxbbr0=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-${fileVersion}-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "10.2" ];
}
rec {
fileVersion = "11.2";
fullVersion = "8.1.1.33";
hash = "sha256-mKh4TpKGLyABjSDCgbMNSgzZUfk2lPZDPM9K6cUCumo=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/cudnn-${fileVersion}-linux-x64-v${fullVersion}.tgz";
supportedCudaVersions = [ "11.2" ];
}
];
"8.3.2" = [
rec {
fileVersion = "10.2";
fullVersion = "8.3.2.44";
hash = "sha256-mKh4TpKGLyABjSDCgbMNSgzZUfk2lPZDPM9K6cUCumo=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/local_installers/${fileVersion}/cudnn-linux-x86_64-${fullVersion}_cuda${fileVersion}-archive.tar.xz";
supportedCudaVersions = [ "10.2" ];
}
rec {
fileVersion = "11.5";
fullVersion = "8.3.2.44";
hash = "sha256-VQCVPAjF5dHd3P2iNPnvvdzb5DpTsm3AqCxyP6FwxFc=";
url = "${urlPrefix}/v${majorMinorPatch fullVersion}/local_installers/${fileVersion}/cudnn-linux-x86_64-${fullVersion}_cuda${fileVersion}-archive.tar.xz";
supportedCudaVersions = [ "11.0" "11.1" "11.2" "11.3" "11.4" "11.4" "11.5" "11.6" ];
}
];
};
# Default attributes
cuDnnDefaultVersion = {
"10.0" = "7.4.2";
"10.1" = "7.6.5";
"10.2" = "8.3.2";
"11.0" = "8.3.2";
"11.1" = "8.3.2";
"11.2" = "8.3.2";
"11.3" = "8.3.2";
"11.4" = "8.3.2";
"11.5" = "8.3.2";
"11.6" = "8.3.2";
}.${cudaVersion};
in cuDnnPackages

View file

@ -0,0 +1,115 @@
{ stdenv
, lib
, zlib
, useCudatoolkitRunfile ? false
, cudaVersion
, cudaMajorVersion
, cudatoolkit # if cuda>=11: only used for .cc
, libcublas ? null # cuda <11 doesn't ship redist packages
, autoPatchelfHook
, autoAddOpenGLRunpathHook
, fetchurl
, # The distributed version of CUDNN includes both dynamically liked .so files,
# as well as statically linked .a files. However, CUDNN is quite large
# (multiple gigabytes), so you can save some space in your nix store by
# removing the statically linked libraries if you are not using them.
#
# Setting this to true removes the statically linked .a files.
# Setting this to false keeps these statically linked .a files.
removeStatic ? false
}:
{ fullVersion
, url
, hash ? null
, sha256 ? null
, supportedCudaVersions ? [ ]
}:
assert (hash != null) || (sha256 != null);
assert useCudatoolkitRunfile || (libcublas != null);
let
inherit (cudatoolkit) cc;
majorMinorPatch = version: lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version));
version = majorMinorPatch fullVersion;
cudatoolkit_root =
if useCudatoolkitRunfile
then cudatoolkit
else libcublas;
in
stdenv.mkDerivation {
pname = "cudatoolkit-${cudaMajorVersion}-cudnn";
inherit version;
src = fetchurl {
inherit url hash sha256;
};
# Check and normalize Runpath against DT_NEEDED using autoPatchelf.
# Prepend /run/opengl-driver/lib using addOpenGLRunpath for dlopen("libcudacuda.so")
nativeBuildInputs = [
autoPatchelfHook
autoAddOpenGLRunpathHook
];
# Used by autoPatchelfHook
buildInputs = [
cc.cc.lib # libstdc++
zlib
cudatoolkit_root
];
# We used to patch Runpath here, but now we use autoPatchelfHook
#
# Note also that version <=8.3.0 contained a subdirectory "lib64/" but in
# version 8.3.2 it seems to have been renamed to simply "lib/".
installPhase = ''
runHook preInstall
mkdir -p $out
cp -a include $out/include
[ -d "lib/" ] && cp -a lib $out/lib
[ -d "lib64/" ] && cp -a lib64 $out/lib64
'' + lib.optionalString removeStatic ''
rm -f $out/lib/*.a
rm -f $out/lib64/*.a
'' + ''
runHook postInstall
'';
# Without --add-needed autoPatchelf forgets $ORIGIN on cuda>=8.0.5.
postFixup = lib.optionalString (lib.versionAtLeast fullVersion "8.0.5") ''
patchelf $out/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so
'';
passthru = {
inherit useCudatoolkitRunfile;
cudatoolkit = lib.warn ''
cudnn.cudatoolkit passthru attribute is deprecated;
if your derivation uses cudnn directly, it should probably consume cudaPackages instead
''
cudatoolkit;
majorVersion = lib.versions.major version;
};
meta = with lib; {
# Check that the cudatoolkit version satisfies our min/max constraints (both
# inclusive). We mark the package as broken if it fails to satisfies the
# official version constraints (as recorded in default.nix). In some cases
# you _may_ be able to smudge version constraints, just know that you're
# embarking into unknown and unsupported territory when doing so.
broken = !(elem cudaVersion supportedCudaVersions);
description = "NVIDIA CUDA Deep Neural Network library (cuDNN)";
homepage = "https://developer.nvidia.com/cudnn";
# TODO: consider marking unfreRedistributable when not using runfile
license = licenses.unfree;
platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ mdaiter samuela ];
};
}