From b73e53258960d3b9252d718e06476c42367dc48d Mon Sep 17 00:00:00 2001 From: thomas Date: Fri, 27 May 2022 18:06:37 +0200 Subject: [PATCH 1/4] Create package file with cp cuda-11.3.1-0.build.sh cuda-11.5.2-0.build.sh --- cuda-11.5.2-0.build.sh | 177 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100755 cuda-11.5.2-0.build.sh diff --git a/cuda-11.5.2-0.build.sh b/cuda-11.5.2-0.build.sh new file mode 100755 index 0000000..27478e6 --- /dev/null +++ b/cuda-11.5.2-0.build.sh @@ -0,0 +1,177 @@ +#! /bin/bash + +# COOKIE=$(mcookie|cut -c-8); grep -v V_GREP_ME $0 > /dev/shm/runme-$COOKIE.sh ; sleep 0.3; exec bash /dev/shm/runme-$COOKIE.sh +# TESTING=1 + +PKG=cuda +MAJOR=11.3 +MINOR=1 +VERSION=$MAJOR.$MINOR +BUILD=0 +DRIVERVERSION=465.19.01 + +CUDNNVER=8.2.1.32 +CUDNNFILE=cudnn-$MAJOR-linux-x64-v$CUDNNVER.tgz + +TENSORRTVER=8.0.1.6 +TENSORRTFILE=TensorRT-$TENSORRTVER.Linux.x86_64-gnu.cuda-$MAJOR.cudnn8.2.tar.gz + +NCCLVER=2.9.9-1 +NCCLFILE=nccl_$NCCLVER+cuda${MAJOR}_x86_64.txz + +PREFIX=/pkg/$PKG-$VERSION-$BUILD +if [ -n "$TESTING" ]; then PREFIX=/dev/shm/$PKG-$VERSION-$BUILD ; fi + +set -e +umask 022 + +# make sure we are not run as root, otherwise the cuda-installer will certainly screw up the machine +test $UID = 0 && echo '# Will not run as root!' && exit 1 + +# this will turn out as showstopper if owned by somebody else, thus fail early... +rm -vf /tmp/cuda-installer.log + +# be carefull on machines with 8Gig and less +BUILD_TMPDIR=/dev/shm/$PKG-$VERSION-$BUILD.build.tmp +test -d $BUILD_TMPDIR && rm -rf $BUILD_TMPDIR +mkdir -p $BUILD_TMPDIR/home +mkdir -p $BUILD_TMPDIR/.local/share/applications +export TMPDIR=$BUILD_TMPDIR +export HOME=$BUILD_TMPDIR/home + +exec $PREFIX/profile <<-EOF + PATH=$PREFIX/bin:\$PATH + export CUDA_PATH=$PREFIX + LD_LIBRARY_PATH=$PREFIX/lib\${LD_LIBRARY_PATH:+:}\$LD_LIBRARY_PATH + if [ -d $PREFIX/.compatlibs ]; then LD_LIBRARY_PATH=$PREFIX/.compatlibs:\$LD_LIBRARY_PATH; fi + export LD_LIBRARY_PATH + PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig\${PKG_CONFIG_PATH:+:}\$PKG_CONFIG_PATH + export PKG_CONFIG_PATH +EOF +. $PREFIX/profile + +cd $PREFIX +BUILDDIR=$PREFIX/build + +mkdir -p $BUILDDIR +cd $BUILDDIR + +### TOOLKIT ### https://developer.nvidia.com/cuda-toolkit + +# https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run +INSTALLFILE=cuda_${VERSION}_${DRIVERVERSION}_linux.run +URL=https://developer.download.nvidia.com/compute/cuda/$VERSION/local_installers/$INSTALLFILE + +# in case it was downloaded before +if [ ! -e $INSTALLFILE -a -e /package/cuda/src/$INSTALLFILE ]; then + cp -vp /package/cuda/src/$INSTALLFILE $INSTALLFILE +fi + +if [ ! -e $INSTALLFILE ]; then + wget $URL +fi + +# $PREFIX/cuda_tmp_dir: this is owed to the demented cuda installer, which happily fails with +# "Unable to write to directory: /pkg", "Permission denied. Unable to write to /pkg/cuda-11.0.3-0/" - what? +# OTOH the installer bundles its libraries and includes a bit better than before +bash $INSTALLFILE \ + --installpath=$PREFIX/cuda_tmp_dir \ + --tmpdir=$TMPDIR \ + --toolkit \ + --samples \ + --silent \ + --nox11 + +### reorganize the tree a bit ### +cd $PREFIX/cuda_tmp_dir + +# fix pc-files (step one) +sed \ + -e '/^cudaroot/ s,/cuda_tmp_dir,,' \ + -i pkgconfig/*.pc + + +# Maybe nsight is of some use, keep it +mv nsight* extras + +# Sanitizer is now at toplevel, put it back to the former location +mv compute-sanitizer extras + +# stuff some of the other 'extras' into 'share', but keep +# - nvvm (nvidia virtual machine, see bin/nvcc.profile) +# - extras (or tensorflow would need extra tweaks, nerve) +mkdir -p share/doc +mv libnvvp nvml tools share + +# fall back to decent locations for lib and include, the other packages do just as different as possible +rm include lib64 +mv targets/x86_64-linux/* . +rm -r targets + +mv pkgconfig lib +# and fix the pc files (step two) +sed \ + -e '/^cudaroot/ s,/$,,' \ + -e 's,/targets/x86_64-linux,,' \ + -i lib/pkgconfig/*.pc + +# adjust nvcc.profile for TARGET_DIR and TARGET_SIZE +sed -e 's,$(_TARGET_SIZE_),,g' \ + -e 's,/$(_TARGET_DIR_),,g' \ + -i bin/nvcc.profile + + +# we don't need this distro aware handler for finding glut & co +for D in $(find -name findgllib.mk -exec dirname {} \;) ; do + test -e $D/Makefile && sed -i -e '/findgllib.mk/ s/include/# include/' $D/Makefile +done + +# and up one level +mv -v * .. ; cd .. ; rmdir cuda_tmp_dir + + +### LIBRARIES ### https://developer.nvidia.com/gpu-accelerated-libraries + +# cudNN +cd $BUILDDIR +test -e $CUDNNFILE || cp /package/cuda/src/$CUDNNFILE . +mkdir -p cudnn +cd cudnn +tar -xf ../$CUDNNFILE +mv cuda/include/cudnn*.h $PREFIX/include +mv cuda/lib64/libcudnn* $PREFIX/lib +mv cuda/NVIDIA_SLA_cuDNN_Support.txt $PREFIX/share/doc + +# TensorRT +cd $BUILDDIR +test -e $TENSORRTFILE || cp /package/cuda/src/$TENSORRTFILE . +mkdir -p TensorRT +cd TensorRT +tar -xf ../$TENSORRTFILE +mv TensorRT-$TENSORRTVER/bin/* $PREFIX/bin +mv TensorRT-$TENSORRTVER/include/* $PREFIX/include +mv TensorRT-$TENSORRTVER/lib/stubs/* $PREFIX/lib/stubs +rmdir TensorRT-$TENSORRTVER/lib/stubs +mv TensorRT-$TENSORRTVER/lib/* $PREFIX/lib + +# nccl - aka 'nickel' +cd $BUILDDIR +test -e $NCCLFILE || cp /package/cuda/src/$NCCLFILE . +mkdir -p nccl +cd nccl +tar -xf ../$NCCLFILE +mv nccl_$NCCLVER+cuda${MAJOR}_x86_64/include/* $PREFIX/include +mv nccl_$NCCLVER+cuda${MAJOR}_x86_64/lib/lib* $PREFIX/lib +# and here we have a pkgconfig too :) +sed -e "/^prefix/ s,/usr/local,$PREFIX," -i nccl_$NCCLVER+cuda${MAJOR}_x86_64/lib/pkgconfig/nccl.pc +mv nccl_$NCCLVER+cuda${MAJOR}_x86_64/lib/pkgconfig/nccl.pc $PREFIX/lib/pkgconfig +mv nccl_$NCCLVER+cuda${MAJOR}_x86_64/LICENSE.txt $PREFIX/share/doc/nccl_LICENSE.txt + +# cosmetics ... +chmod -c -x $PREFIX/include/*.{h,hpp} +test -e /tmp/cuda-installer.log && mv -v /tmp/cuda-installer.log $PREFIX + +exit From 44e8678e8866a4417e3c9bec7204860e53c8a547 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 2 Jun 2022 08:59:31 +0200 Subject: [PATCH 2/4] cuda-11.5.2: raise versions, adjust cudnn archive The cudnn-package has changed the layout a bit, also the library dir has switched from lib64 to lib (I'm curious when there will be a consistent layout) Concerning 'TensorRT...>>>cuda-11.6<<<.cudnn8.3.tar.gz The full description reads: TensorRT 8.4 EA for Linux x86_64 and CUDA 11.0, 11.1, 11.2, 11.3, 11.4, 11.5 and 11.6 So it should be safe to use it, albeit it looks like an error. Plugging the CUDA-suite together resembles more and more the clutter known from GTK. --- cuda-11.5.2-0.build.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/cuda-11.5.2-0.build.sh b/cuda-11.5.2-0.build.sh index 27478e6..630d6ca 100755 --- a/cuda-11.5.2-0.build.sh +++ b/cuda-11.5.2-0.build.sh @@ -4,19 +4,19 @@ # TESTING=1 PKG=cuda -MAJOR=11.3 -MINOR=1 +MAJOR=11.5 +MINOR=2 VERSION=$MAJOR.$MINOR BUILD=0 -DRIVERVERSION=465.19.01 +DRIVERVERSION=495.29.05 -CUDNNVER=8.2.1.32 -CUDNNFILE=cudnn-$MAJOR-linux-x64-v$CUDNNVER.tgz +CUDNNVER=8.3.3.40 +CUDNNFILE=cudnn-linux-x86_64-${CUDNNVER}_cuda$MAJOR-archive.tar.xz -TENSORRTVER=8.0.1.6 -TENSORRTFILE=TensorRT-$TENSORRTVER.Linux.x86_64-gnu.cuda-$MAJOR.cudnn8.2.tar.gz +TENSORRTVER=8.4.0.6 +TENSORRTFILE=TensorRT-$TENSORRTVER.Linux.x86_64-gnu.cuda-11.6.cudnn8.3.tar.gz -NCCLVER=2.9.9-1 +NCCLVER=2.11.4-1 NCCLFILE=nccl_$NCCLVER+cuda${MAJOR}_x86_64.txz PREFIX=/pkg/$PKG-$VERSION-$BUILD @@ -141,9 +141,10 @@ test -e $CUDNNFILE || cp /package/cuda/src/$CUDNNFILE . mkdir -p cudnn cd cudnn tar -xf ../$CUDNNFILE -mv cuda/include/cudnn*.h $PREFIX/include -mv cuda/lib64/libcudnn* $PREFIX/lib -mv cuda/NVIDIA_SLA_cuDNN_Support.txt $PREFIX/share/doc + +ARCHDIR=${CUDNNFILE%.tar.xz} +mv $ARCHDIR/include/cudnn*.h $PREFIX/include +mv $ARCHDIR/lib/libcudnn* $PREFIX/lib # TensorRT cd $BUILDDIR From aa30856768e8f9f55d7fad304cfd49d8301c0b68 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 2 Jun 2022 09:11:27 +0200 Subject: [PATCH 3/4] cuda-11.5.2: use /package/cuda/src for all packages cuda-XY_linux.run is the only package that can be downloaded w/o a developer account. For the sake of consistency this option is dropped. --- cuda-11.5.2-0.build.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/cuda-11.5.2-0.build.sh b/cuda-11.5.2-0.build.sh index 630d6ca..d155c19 100755 --- a/cuda-11.5.2-0.build.sh +++ b/cuda-11.5.2-0.build.sh @@ -9,6 +9,7 @@ MINOR=2 VERSION=$MAJOR.$MINOR BUILD=0 DRIVERVERSION=495.29.05 +CUDAFILE=cuda_${VERSION}_${DRIVERVERSION}_linux.run CUDNNVER=8.3.3.40 CUDNNFILE=cudnn-linux-x86_64-${CUDNNVER}_cuda$MAJOR-archive.tar.xz @@ -59,25 +60,13 @@ BUILDDIR=$PREFIX/build mkdir -p $BUILDDIR cd $BUILDDIR -### TOOLKIT ### https://developer.nvidia.com/cuda-toolkit -# https://developer.download.nvidia.com/compute/cuda/11.4.0/local_installers/cuda_11.4.0_470.42.01_linux.run -INSTALLFILE=cuda_${VERSION}_${DRIVERVERSION}_linux.run -URL=https://developer.download.nvidia.com/compute/cuda/$VERSION/local_installers/$INSTALLFILE - -# in case it was downloaded before -if [ ! -e $INSTALLFILE -a -e /package/cuda/src/$INSTALLFILE ]; then - cp -vp /package/cuda/src/$INSTALLFILE $INSTALLFILE -fi - -if [ ! -e $INSTALLFILE ]; then - wget $URL -fi +test -e $CUDAFILE || cp -vp /package/cuda/src/$CUDAFILE . # $PREFIX/cuda_tmp_dir: this is owed to the demented cuda installer, which happily fails with # "Unable to write to directory: /pkg", "Permission denied. Unable to write to /pkg/cuda-11.0.3-0/" - what? # OTOH the installer bundles its libraries and includes a bit better than before -bash $INSTALLFILE \ +bash $CUDAFILE \ --installpath=$PREFIX/cuda_tmp_dir \ --tmpdir=$TMPDIR \ --toolkit \ From dc2a8b2a5319dc3147f6006d9bef5298984edff9 Mon Sep 17 00:00:00 2001 From: thomas Date: Thu, 2 Jun 2022 10:28:42 +0200 Subject: [PATCH 4/4] cuda-11.5.2: be a bit chatty --- cuda-11.5.2-0.build.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/cuda-11.5.2-0.build.sh b/cuda-11.5.2-0.build.sh index d155c19..b90a801 100755 --- a/cuda-11.5.2-0.build.sh +++ b/cuda-11.5.2-0.build.sh @@ -61,6 +61,7 @@ mkdir -p $BUILDDIR cd $BUILDDIR +echo "# Working on: $CUDAFILE" test -e $CUDAFILE || cp -vp /package/cuda/src/$CUDAFILE . # $PREFIX/cuda_tmp_dir: this is owed to the demented cuda installer, which happily fails with @@ -126,7 +127,9 @@ mv -v * .. ; cd .. ; rmdir cuda_tmp_dir # cudNN cd $BUILDDIR -test -e $CUDNNFILE || cp /package/cuda/src/$CUDNNFILE . + +echo "# Working on: $CUDNNFILE" +test -e $CUDNNFILE || cp -vp /package/cuda/src/$CUDNNFILE . mkdir -p cudnn cd cudnn tar -xf ../$CUDNNFILE @@ -137,7 +140,9 @@ mv $ARCHDIR/lib/libcudnn* $PREFIX/lib # TensorRT cd $BUILDDIR -test -e $TENSORRTFILE || cp /package/cuda/src/$TENSORRTFILE . + +echo "# Working on: $TENSORRTFILE" +test -e $TENSORRTFILE || cp -vp /package/cuda/src/$TENSORRTFILE . mkdir -p TensorRT cd TensorRT tar -xf ../$TENSORRTFILE @@ -149,7 +154,9 @@ mv TensorRT-$TENSORRTVER/lib/* $PREFIX/lib # nccl - aka 'nickel' cd $BUILDDIR -test -e $NCCLFILE || cp /package/cuda/src/$NCCLFILE . + +echo "# Working on: $NCCLFILE" +test -e $NCCLFILE || cp -vp /package/cuda/src/$NCCLFILE . mkdir -p nccl cd nccl tar -xf ../$NCCLFILE