Skip to content

Commit

Permalink
Provide a more informative fallback if CUDA is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
fwyzard committed Nov 25, 2021
1 parent 47863b5 commit bb1cc87
Showing 1 changed file with 44 additions and 7 deletions.
51 changes: 44 additions & 7 deletions cuda-compatible-runtime.spec
Expand Up @@ -15,16 +15,53 @@ AutoReq: no
# defines nvcc_stdcxx and cuda_flags_4

rm -rf %{_builddir}/build && mkdir %{_builddir}/build
$CUDA_ROOT/bin/nvcc %{nvcc_stdcxx} -O2 -g %{cuda_flags_4} test.cu -I $CUDA_ROOT/include -L $CUDA_ROOT/lib64 -L $CUDA_ROOT/lib64/stubs --cudart static -ldl -lrt --compiler-options '-Wall -pthread' -o %{_builddir}/build/cuda-compatible-runtime # || true
if
$CUDA_ROOT/bin/nvcc %{nvcc_stdcxx} -O2 -g %{cuda_flags_4} test.cu -I $CUDA_ROOT/include -L $CUDA_ROOT/lib64 -L $CUDA_ROOT/lib64/stubs --cudart static -ldl -lrt --compiler-options '-Wall -pthread' -o %{_builddir}/build/cuda-compatible-runtime
then
true
else
# CUDA is not supported by this architecture or compiler version
cat > %{_builddir}/build/cuda-compatible-runtime << @EOF_
#! /bin/bash

VERBOSE=false

%install
function usage() {
cat << @EOF
Usage: \$0 [-h|-v]

mkdir %{i}/test
if [ -f %{_builddir}/build/cuda-compatible-runtime ]; then
cp %{_builddir}/build/cuda-compatible-runtime %{i}/test/cuda-compatible-runtime
else
ln -s /usr/bin/false %{i}/test/cuda-compatible-runtime
Options:
-h Print a help message and exits.
-v Be more verbose.
@EOF
}

for ARG in "\$@"; do
case "\$ARG" in
-h)
usage
exit 0
;;
-v)
VERBOSE=true
;;
*)
echo "\$0: invalid option '\$ARG'"
echo
usage
exit 1
;;
esac
done

\$VERBOSE && echo "CUDA ${CUDA_VERSION} is not compatible with GCC ${GCC_VERSION}"
exit 1
@EOF_
chmod +x %{_builddir}/build/cuda-compatible-runtime
fi

%install
mkdir %{i}/test
cp %{_builddir}/build/cuda-compatible-runtime %{i}/test/cuda-compatible-runtime

%post

0 comments on commit bb1cc87

Please sign in to comment.