Created
October 22, 2019 17:29
-
-
Save dtw-waleee/6d42951e3f8da9c6a66f5b517bdae9ee to your computer and use it in GitHub Desktop.
overriding version to 10.1
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
(self: super: { | |
cudatoolkit = super.cudatoolkit.overrideAttrs (old: rec { | |
version = "10.1.243"; | |
src = super.fetchurl { | |
url = "https://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run"; | |
sha256 = "0caxhlv2bdq863dfp6wj7nad66ml81vasq2ayf11psvq2b12vhp9"; | |
}; | |
unpackPhase = '' | |
sh $src --keep --noexec | |
${super.lib.optionalString (super.lib.versionOlder version "10.1") '' | |
cd pkg/run_files | |
sh cuda-linux*.run --keep --noexec | |
sh cuda-samples*.run --keep --noexec | |
mv pkg ../../$(basename $src) | |
cd ../.. | |
rm -rf pkg | |
for patch in $runPatches; do | |
sh $patch --keep --noexec | |
mv pkg $(basename $patch) | |
done | |
''} | |
''; | |
installPhase = '' | |
runHook preInstall | |
mkdir $out | |
${super.lib.optionalString (super.lib.versionOlder version "10.1") '' | |
cd $(basename $src) | |
export PERL5LIB=. | |
perl ./install-linux.pl --prefix="$out" | |
cd .. | |
for patch in $runPatches; do | |
cd $(basename $patch) | |
perl ./install_patch.pl --silent --accept-eula --installdir="$out" | |
cd .. | |
done | |
''} | |
${super.lib.optionalString (super.lib.versionAtLeast version "10.1") '' | |
cd pkg/builds/cuda-toolkit | |
mv * $out/ | |
''} | |
rm $out/tools/CUDA_Occupancy_Calculator.xls # FIXME: why? | |
${super.lib.optionalString (super.lib.versionOlder version "10.1") '' | |
# let's remove the 32-bit libraries, they confuse the lib64->lib mover | |
rm -rf $out/lib | |
''} | |
# Remove some cruft. | |
${super.lib.optionalString ((super.lib.versionAtLeast version "7.0") && (super.lib.versionOlder version "10.1")) | |
"rm $out/bin/uninstall*"} | |
# Fixup path to samples (needed for cuda 6.5 or else nsight will not find them) | |
if [ -d "$out"/cuda-samples ]; then | |
mv "$out"/cuda-samples "$out"/samples | |
fi | |
# Change the #error on GCC > 4.9 to a #warning. | |
sed -i $out/include/host_config.h -e 's/#error\(.*unsupported GNU version\)/#warning\1/' | |
# Fix builds with newer glibc version | |
sed -i "1 i#define _BITS_FLOATN_H" "$out/include/host_defines.h" | |
# Ensure that cmake can find CUDA. | |
mkdir -p $out/nix-support | |
echo "cmakeFlags+=' -DCUDA_TOOLKIT_ROOT_DIR=$out'" >> $out/nix-support/setup-hook | |
# Move some libraries to the lib output so that programs that | |
# depend on them don't pull in this entire monstrosity. | |
mkdir -p $lib/lib | |
mv -v $out/lib64/libcudart* $lib/lib/ | |
# Remove OpenCL libraries as they are provided by ocl-icd and driver. | |
rm -f $out/lib64/libOpenCL* | |
${super.lib.optionalString (super.lib.versionAtLeast version "10.1") '' | |
mv $out/lib64 $out/lib | |
''} | |
# Set compiler for NVCC. | |
wrapProgram $out/bin/nvcc \ | |
--prefix PATH : ${super.gcc7}/bin | |
# nvprof do not find any program to profile if LD_LIBRARY_PATH is not set | |
wrapProgram $out/bin/nvprof \ | |
--prefix LD_LIBRARY_PATH : $out/lib | |
'' + super.lib.optionalString (super.lib.versionOlder version "8.0") '' | |
# Hack to fix building against recent Glibc/GCC. | |
echo "NIX_CFLAGS_COMPILE+=' -D_FORCE_INLINES'" >> $out/nix-support/setup-hook | |
'' + '' | |
runHook postInstall | |
''; | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment