FS#49272 - [cuda] Does not work with gcc 6.1.1
Attached to Project:
Community Packages
Opened by pavan yalamanchili (pavanky) - Monday, 09 May 2016, 00:53 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Tuesday, 12 July 2016, 08:11 GMT
Opened by pavan yalamanchili (pavanky) - Monday, 09 May 2016, 00:53 GMT
Last edited by Sven-Hendrik Haase (Svenstaro) - Tuesday, 12 July 2016, 08:11 GMT
|
Details
g++ defaults to c++14 for gcc 6.1, where as nvcc (which
officially only supports) assumes the default is still
c++98
Problem 1: This causes problems when trying to compile simple cuda kernels. Attached is a file called (math.cu) which can reproduce this issue by running the following command: nvcc -c math.cu The errors generated are attached as default-options-errors.txt ------------------------------------- Problem 2: The above problem has a seemingly simple fix: pass -std=c++11 to nvcc which supports it. This however is causing a new kind of conflict with math operations. Running the following command generates errors present in attachment named (std_c++11_errors.txt) nvcc -std=c++11 -c math.cu Please note the above works fine with gcc-5.3.0. The conflict seems to happen only on gcc 6.1.1 where something in the compilation process is importing the entire std namespace. ---------------------------------------- P.S. This is a problem from upstream, but I am creating the issue on request from the cuda package maintainer as mentioned here: https://www.reddit.com/r/archlinux/comments/4iczja/a_work_around_if_you_are_using_cuda_and_have/d2xubjm |
This task depends upon
Closed by Sven-Hendrik Haase (Svenstaro)
Tuesday, 12 July 2016, 08:11 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed by using gcc5 for the foreseeable time.
Tuesday, 12 July 2016, 08:11 GMT
Reason for closing: Fixed
Additional comments about closing: Fixed by using gcc5 for the foreseeable time.
I think the problem is in the nightmarish `math_functions.h` file. I am going to experiment a little bit when I have the time to try it out.
cc1: warning: command line option ‘-std=c++98’ is valid for C++/ObjC++ but not for C
even when compiling pure C++ code, but what the hell...
New update:
A commentor on reddit[1] pointed out adding "-std=c++11 -Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO" fixes the issues with math functions.
I was able to compile the math.cu file without any problems.
ArrayFire is still having issues which I am going to figure out.
[1] https://www.reddit.com/r/archlinux/comments/4iczja/a_work_around_if_you_are_using_cuda_and_have/d30duqi
The define hopefully wouldn't break any existing code as g++ only started wrapping math.h in v6.
[1] http://phoronix.com/scan.php?page=news_item&px=CUDA-8-Release-Candidate
Phoronix says (http://phoronix.com/scan.php?page=news_item&px=CUDA-8-Release-Candidate):
> NVIDIA has made public the release candidate for CUDA 8.
NVIDIA says (https://developer.nvidia.com/cuda-toolkit):
> Download the CUDA Toolkit 8 RC today; requires membership of the the Accelerated Computing Developer Program
You just need to sign up for it. I am not sure if they even have a waiting period.
Here are my results so far:
- Anyway the installer complains about not supporting gcc 6.1.1
- host_config.h complains if gcc compiler version > 5.3. I commented this out for testing.
- still need to pass '-std=c++11 -Xcompiler -D__CORRECT_ISO_CPP11_MATH_H_PROTO' to get kernels to compile
- including stl headers in files with just CUDA kernels is not an issue
- including stl headers in files with any host code is still giving issues
> /opt/cuda-8.0-rc1/bin/nvcc -ccbin clang++ -Xcompiler -stdlib=libc++ -Xlinker -lc++abi /tmp/math.cu -std=c++11
Note: clang with libstdc++ does not work either.
I am going to test building with clang 3.8 on a larger code base and let you know how it goes.
https://developer.nvidia.com/compute/cuda/8.0/rc/local_installers/cuda_8.0.27_linux-run
But like pavanky said, it is still broken with GCC 6, so it doesn't really matter. The only option seems to use an old GCC.
As it stands, here are the work arounds:
- install gcc 5.3 to use CUDA without any problems (works with CUDA 7.5, CUDA 8.0)
- pass -std=c++98, if you want to use gcc 6.1 (works with CUDA 7.5, CUDA 8.0)
- pass -std=c++11 -ccbin clang++ -Xcompiler -stdlib=libc++ -Xlinker -lc++abi if you want C++11 (works only with CUDA 8.0, clang, libc++)
None of this provides an actual solution to packaging, but I am noting it down if someone want's to patch their project manually.
-Xcompiler -nostdinc++ -Xcompiler -I/usr/include/c++/v1 -Xlinker -lc++
As for the last option, using gcc with clang's stl, do you know of any project that does this?
Next time I'm at the lab I'll figure out how to tell bazel to compile tensorflow (... sigh) with both gcc6 and clang.
Im also digging into the temporary files to see what's causing the breakage. Aa you can understand, parsing through 30k-60k lines is a bit daunting.
- install gcc5 from AUR
- copy the stdc++ headers from an old gcc 5.3.0 package to /usr/include/c++/5.3.0/ (just google for `gcc-5.3.0-5-x86_64.pkg.tar.xz`, they are not part of the AUR gcc5 package)
- pass -std=c++11 -ccbin clang++ -Xcompiler --gcc-toolchain=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/ -Xcompiler -I/usr/include/c++/5.3.0 -Xcompiler -I/usr/include/c++/5.3.0/x86_64-unknown-linux-gnu to nvcc
I only tested it using CUDA 8.0 (with clang 3.8), but it might also work using CUDA 7.5 (with clang 3.6)
EDIT:
for the gcc5 package from the community repo you can skip the second step and pass the following to nvcc:
-std=c++11 -ccbin clang++ -Xcompiler --gcc-toolchain=/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/ -Xcompiler -I/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++ -Xcompiler -I/usr/lib/gcc/x86_64-pc-linux-gnu/5.4.0/include/c++/x86_64-pc-linux-gnu
By the way, CUDA 8.0 will check if GCC<=5.x.x, so we can just keep that check (not remove it[1]) and users will get the nice original notification that CUDA is not compatible with GCC 6 if they try to use it.
[1] https://git.archlinux.org/svntogit/community.git/tree/trunk/PKGBUILD?h=packages/cuda#n51
On the news side, it seems highly unlikely NVIDIA is going to support gcc6 for a very long time.
@svenstaro, Would it be possible to add a message to the package mentioning that GCC6 is not compatible out of the box and point to potential workarounds (e.g this issue).