lol

Merge pull request #267247 from yannham/feat/cuda-compat-jetson

Use cuda_compat drivers when available

authored by

Connor Baker and committed by
GitHub
9ad72f82 f3cb1994

+56
+9
pkgs/development/cuda-modules/generic-builders/manifest.nix
··· 1 1 { 2 2 # General callPackage-supplied arguments 3 3 autoAddOpenGLRunpathHook, 4 + autoAddCudaCompatRunpathHook, 4 5 autoPatchelfHook, 5 6 backendStdenv, 6 7 fetchurl, ··· 126 127 # Check e.g. with `patchelf --print-rpath path/to/my/binary 127 128 autoAddOpenGLRunpathHook 128 129 markForCudatoolkitRootHook 130 + ] 131 + # autoAddCudaCompatRunpathHook depends on cuda_compat and would cause 132 + # infinite recursion if applied to `cuda_compat` itself (beside the fact 133 + # that it doesn't make sense in the first place) 134 + ++ lib.optionals (pname != "cuda_compat" && flags.isJetsonBuild) [ 135 + # autoAddCudaCompatRunpathHook must appear AFTER autoAddOpenGLRunpathHook. 136 + # See its documentation in ./setup-hooks/extension.nix. 137 + autoAddCudaCompatRunpathHook 129 138 ]; 130 139 131 140 buildInputs =
+27
pkgs/development/cuda-modules/setup-hooks/auto-add-cuda-compat-runpath.sh
··· 1 + # shellcheck shell=bash 2 + # Patch all dynamically linked, ELF files with the CUDA driver (libcuda.so) 3 + # coming from the cuda_compat package by adding it to the RUNPATH. 4 + echo "Sourcing auto-add-cuda-compat-runpath-hook" 5 + 6 + elfHasDynamicSection() { 7 + patchelf --print-rpath "$1" >& /dev/null 8 + } 9 + 10 + autoAddCudaCompatRunpathPhase() ( 11 + local outputPaths 12 + mapfile -t outputPaths < <(for o in $(getAllOutputNames); do echo "${!o}"; done) 13 + find "${outputPaths[@]}" -type f -executable -print0 | while IFS= read -rd "" f; do 14 + if isELF "$f"; then 15 + # patchelf returns an error on statically linked ELF files 16 + if elfHasDynamicSection "$f" ; then 17 + echo "autoAddCudaCompatRunpathHook: patching $f" 18 + local origRpath="$(patchelf --print-rpath "$f")" 19 + patchelf --set-rpath "@libcudaPath@:$origRpath" "$f" 20 + elif (( "${NIX_DEBUG:-0}" >= 1 )) ; then 21 + echo "autoAddCudaCompatRunpathHook: skipping a statically-linked ELF file $f" 22 + fi 23 + fi 24 + done 25 + ) 26 + 27 + postFixupHooks+=(autoAddCudaCompatRunpathPhase)
+20
pkgs/development/cuda-modules/setup-hooks/extension.nix
··· 44 44 ./auto-add-opengl-runpath-hook.sh 45 45 ) 46 46 {}; 47 + 48 + # autoAddCudaCompatRunpathHook hook must be added AFTER `setupCudaHook`. Both 49 + # hooks prepend a path with `libcuda.so` to the `DT_RUNPATH` section of 50 + # patched elf files, but `cuda_compat` path must take precedence (otherwise, 51 + # it doesn't have any effect) and thus appear first. Meaning this hook must be 52 + # executed last. 53 + autoAddCudaCompatRunpathHook = 54 + final.callPackage 55 + ( 56 + {makeSetupHook, cuda_compat}: 57 + makeSetupHook 58 + { 59 + name = "auto-add-cuda-compat-runpath-hook"; 60 + substitutions = { 61 + libcudaPath = "${cuda_compat}/compat"; 62 + }; 63 + } 64 + ./auto-add-cuda-compat-runpath.sh 65 + ) 66 + {}; 47 67 }