There is a number of difficulties installing NVIDIA CUDA SDK 5.0 onto OpenSUSE 12.3. The major reason that it does not support gcc 4.7.2 compiler that is distribution's default. There is a number of ways to overcome it.
1. install drivers. You may use packages from OpenSUSE's NVidia repository or use the ones that come with cuda-sdk package. Both cases work fine, just make sure your driver's version maches the requirement.
I guess the same steps may apply to other Linux distributions with gcc 4.7, like Ubuntu 12.10 and etc, that it How to make nVidia cuda sdk 5.0 to work with gcc 4.7
1. install drivers. You may use packages from OpenSUSE's NVidia repository or use the ones that come with cuda-sdk package. Both cases work fine, just make sure your driver's version maches the requirement.
There may be a problem with missing libraries, like libglut.so, just fix them with appropriate symlinks in your /usr/lib64 .
2. install cuda-sdk. Get the package from https://developer.nvidia.com/cuda-downloads. I used version for openSuSE 12.1. Install as superuser it with the following options:
su -
./cuda_5.0.35_linux_64_suse12.1-1.bin -toolkit -samples -override
These options disable installation of NVidia drivers and skip the dependency checks.
Consider you've installed it into its default directory, i.e. /usr/local/cuda-5.0.
(for other options see ./cuda_5.0.35_linux_64_suse12.1-1.bin --help)
Go to this directory, and do the following
3. disable GCC version check:
open /usr/local/cuda-5.0/include/host_config.h
find
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
and replace it with
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)
That alone won't help, and if you try to compile the samples you'll most likely get compile time errors like:
/usr/include/c++/4.7/ext/atomicity.h(48): error: identifier "__atomic_fetch_add" is undefined
/usr/include/c++/4.7/ext/atomicity.h(52): error: identifier "__atomic_fetch_add" is undefined
4. To disable there "__atomic_fetch_add is undefined" compiler errors:
You have to include commands like
#undef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_USE_INT128
into beginning of you .cu file or put them into a separate include file. Lets put them into
/usr/local/cuda-5.0/include/__cuda_gcc47_fix.h
or other name you like. Now you may compile a hello world application with
nvcc --pre-include __cuda_gcc47_fix.h command
in order to have the whole "samples" directory compile with default makefiles, lets do a little trick.
save nvcc binary into a separate file, and create a small wrapper script with the following commands:
cd /usr/local/cuda-5.0
mv bin/nvcc bin/nvcc.bin
echo '#!/bin/sh
$0.bin --pre-include __cuda_gcc47_fix.h $@' > bin/nvcc
chmod +x bin/nvcc
After that the whole samples directory should compile without errors. (check for mpicxx to work in order to build some samples). Warnings on delegating contructors may be ignored.
I guess the same steps may apply to other Linux distributions with gcc 4.7, like Ubuntu 12.10 and etc, that it How to make nVidia cuda sdk 5.0 to work with gcc 4.7