Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 132 lines (101 sloc) 3.85 KB
#! /bin/bash
PKG=cuda
MAJOR=9.2
MINOR=148
VERSION=${MAJOR}.${MINOR}
BUILD=0
DRIVERVERSION=396.37
CUDNNVER=7.2.1.38
# This update includes performance improvements to cuBLAS GEMM APIs and bug fixes
# for CUPTI and cuda-gdb. See the CUDA 9.2 release notes for more details.
PATCH=cuda_$VERSION.1_linux.run
# get versions combination and file URL from
# https://developer.nvidia.com/cuda-downloads?target_os=Linux
# Linux - x86_64 - any - any - runfile (local) -- Note: 'any' means 'any' from the options given
#
# the cuda toolkit comes bundled with a (kernel) driver. Here we only install the toolkit.
# It seems to function with other driver versions, but this can't be relied on.
# Additonal we install cudnn7 which comes in variants for each cuda version.
CUDNNFILE=cudnn-$MAJOR-linux-x64-v$CUDNNVER.tgz
#
# this file can only be downloaded with a developer login. Dowload drom
# https://developer.nvidia.com/cudnn
# and put the file into /package/cuda/src
# Note:
# https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html
# "The CUDA Development Tools are only supported on some specific distributions of Linux. These are listed in the CUDA Toolkit release notes."
PREFIX=/pkg/$PKG-$VERSION-$BUILD
# PREFIX=/dev/shm/$PKG-$VERSION-$BUILD
set -xe
umask 022
BUILD_TMPDIR=/dev/shm/$PKG-$VERSION-$BUILD.build.tmp
test -d $BUILD_TMPDIR && rm -rf $BUILD_TMPDIR
mkdir -p $BUILD_TMPDIR/home
export TMPDIR=$BUILD_TMPDIR
export HOME=$BUILD_TMPDIR/home
exec </dev/null
mkdir -p $PREFIX
cat >$PREFIX/profile <<-EOF
PATH=$PREFIX/bin:\$PATH
export LD_LIBRARY_PATH=$PREFIX/lib64\${LD_LIBRARY_PATH:+:\$LD_LIBRARY_PATH}
EOF
. $PREFIX/profile
export MAKEFLAGS="-j $(nproc)"
BUILDDIR=$PREFIX/build
mkdir -p $BUILDDIR
cd $BUILDDIR
# URL from https://developer.nvidia.com/cuda-downloads?target_os=Linux
# Linux - x86_64 - any - any - runfile (local)
INSTALLFILE=cuda_${VERSION}_${DRIVERVERSION}_linux
URL=https://developer.nvidia.com/compute/cuda/$MAJOR/Prod2/local_installers/$INSTALLFILE
# in case it was downloaded before
if [ -e /package/cuda/src/$INSTALLFILE.run ]; then
cp -vp /package/cuda/src/$INSTALLFILE.run $INSTALLFILE
fi
if [ ! -e ${INSTALLFILE} ]; then
wget $URL
fi
# We have the first-level of "Makeself tool" generated script/archive.
# We just extract to tmp and dont run the content
test -d "cuda" || bash ${INSTALLFILE} --nox11 --target cuda --noexec
cd cuda
# we dont run the installer.
# perl ./cuda-installer.pl --silent --toolkit --toolkitpath=${PREFIX} --verbose
# would do all kind of stupid things and the call in run-files
# ./cuda-linux.9.1.85-23083092.run --nox11 -- --noprompt --prefix="/dev/shm/x" --manifest="/dev/shm/x/bin/.uninstall_manifest_do_not_delete.txt"
#
# instead do it ourself
cd run_files
script=cuda-linux.*.run
# again, cuda-linux-SOMETHING.run is a "Makeself tool" generated script.
# We just extract to tmp and dont run the content
test -d cuda-linux || bash $script --nox11 --target cuda-linux --noexec
# apply the patch, installdir must point to 'version.txt' file
cd $BUILDDIR
cp -p /package/cuda/src/$PATCH .
# must do an '--accept-eula', and it brings up a terminal window as OK-button
bash $PATCH --silent --accept-eula --installdir=$BUILDDIR/cuda/run_files/cuda-linux
cd cuda/run_files/cuda-linux
# we dont run the installer
# perl ./install-linux.pl --prefix=$PREFIX --noprompt
# would do all kind of stupid things like deleting evertyhing in $PREFIX
# the main thing it does is this:
find * -type d -prune -exec cp -a {} $PREFIX/ \;
# copy the samples....
#
#cd ..
#script=cuda-samples.*.run
#test -d cuda-samples || bash $script --nox11 --target cuda-samples --noexec
#cd cuda-samples
#cp -a samples $PREFIX/
# cudNN
#
cd $BUILDDIR
test -e $CUDNNFILE || cp /package/cuda/src/$CUDNNFILE .
test -d cudnn || mkdir cudnn
cd cudnn
tar xvf ../$CUDNNFILE
cp cuda/include/cudnn.h $PREFIX/include/
cp cuda/lib64/libcudnn* $PREFIX/lib64/
# exit 1
exit