CUDA 6.5抱怨不支持gcc 4.9 - 该怎么办? [英] CUDA 6.5 complains about not supporting gcc 4.9 - what to do?
问题描述
我刚刚从Kubuntu 12.04升级到14.04。现在,当我想编译CUDA代码(使用CUDA 6.5)时,我得到:
#error - 不支持的GNU版本!不支持gcc 4.9及以上版本!
我安装了gcc-4.8(和4.7),并尝试使用符号链接c $ c> / usr / local / cuda / bin 此处建议的解决方案:
但这不起作用。
此解决方案与CUDA和GCC版本的多种组合相关。
您可以告诉CUDA的 nvcc
使用特定版本gcc。所以,假设你想要gcc 4.7与CUDA一起使用。您执行:
sudo apt-get install gcc-4.7 g ++ - 4.7
/ pre>
,然后将以下开关添加到您的
nvcc
命令行:nvcc --compiler-bindir /usr/bin/gcc-4.7此处的命令行的#rest
如果您正在使用CMake构建,请在查找CUDA到您的
CMakeLists.txt
,例如:set(CUDA_HOST_COMPILER /usr/bin/gcc-4.7)# - >添加此行< -
find_package(CUDA)
CUDA,也许这值得尝试(虽然你必须适当地构建它)。
注意 gcc的多个版本的软件包(在同一版本的发行版中)。我建议反对尝试从另一个版本的发行版强制安装一个包,并考虑构建gcc。这不是微不足道,但它是很可行 - 当然,唯一的选择,如果你不是根。
I've just dist-upgraded from Kubuntu 12.04 to 14.04. Now, when I want to compile CUDA code (with CUDA 6.5), I get:
#error -- unsupported GNU version! gcc 4.9 and up are not supported!
I installed gcc-4.8 (and 4.7), and tried to use the symlinks-in-
/usr/local/cuda/bin
solution suggested here:CUDA incompatible with my gcc version
but this doesn't work. What should I do?
解决方案This solution is relevant to multiple combinations of CUDA and GCC versions.
You can tell CUDA's
nvcc
to use a specific version of gcc. So, suppose you want gcc 4.7 for use with CUDA. You run:sudo apt-get install gcc-4.7 g++-4.7
and then add the following switch to your
nvcc
command-line:nvcc --compiler-bindir /usr/bin/gcc-4.7 # rest of the command line here
If you're building with CMake, add an appropriate setting before looking for CUDA to your
CMakeLists.txt
, e.g.:set(CUDA_HOST_COMPILER /usr/bin/gcc-4.7) # -> ADD THIS LINE <- find_package(CUDA)
Also, it seems clang can compile CUDA as well, maybe that's worth experimenting with (although you would have to build it appropriately).
Note: Some distributions don't have packages for multiple versions of gcc (in the same release of the distro). I would advise against trying to force-installing a package from another release of the distro, and consider building gcc. That's not trivial but it is quite doable - and of course, the only option if you're not root.
这篇关于CUDA 6.5抱怨不支持gcc 4.9 - 该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!