-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable cuda_compat by default on Jetson devices
Some nvidia devices, such as the Jetson family, support the Nvidia compatibility package (nvidia_compat) which allows to run executables built against a higher CUDA major version on a system with an older CUDA driver. On such platforms, the consensus among CUDA maintainers is that there is no downside in always enabling it by default. This commit links to the relevant cuda_compat shared libraries by patching the CUDA core packages' runpaths when cuda_compat is available, in the same way as we do for OpenGL drivers currently.
- Loading branch information
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
pkgs/development/cuda-modules/setup-hooks/auto-add-cuda-compat-runpath.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# shellcheck shell=bash | ||
# Patch all dynamically linked, ELF files with the CUDA driver (libcuda.so) | ||
# coming from the cuda_compat package by adding it to the RUNPATH. | ||
echo "Sourcing auto-add-cuda-compat-runpath-hook" | ||
|
||
elfHasDynamicSection() { | ||
patchelf --print-rpath "$1" >& /dev/null | ||
} | ||
|
||
autoAddCudaCompatRunpathPhase() ( | ||
local outputPaths | ||
mapfile -t outputPaths < <(for o in $(getAllOutputNames); do echo "${!o}"; done) | ||
find "${outputPaths[@]}" -type f -executable -print0 | while IFS= read -rd "" f; do | ||
if isELF "$f"; then | ||
# patchelf returns an error on statically linked ELF files | ||
if elfHasDynamicSection "$f" ; then | ||
echo "autoAddCudaCompatRunpathHook: patching $f" | ||
local origRpath="$(patchelf --print-rpath "$f")" | ||
patchelf --set-rpath "@libcudaPath@:$origRpath" "$f" | ||
elif (( "${NIX_DEBUG:-0}" >= 1 )) ; then | ||
echo "autoAddCudaCompatRunpathHook: skipping a statically-linked ELF file $f" | ||
fi | ||
fi | ||
done | ||
) | ||
|
||
postFixupHooks+=(autoAddCudaCompatRunpathPhase) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters