CUDA版本X抱怨不支持gcc版本Y - 该怎么办? [英] CUDA version X complains about not supporting gcc version Y - what to do?

查看:1811
本文介绍了CUDA版本X抱怨不支持gcc版本Y - 该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是关于一个特定的版本组合,但更相关一般。

我刚刚从Kubuntu 12.04升级至14.04。现在,当我想编译CUDA代码(使用CUDA 6.5)时,我得到:

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!

我安装了gcc-4.8(和4.7),并尝试使用符号链接c $ c> / usr / local / cuda / bin 此处建议的解决方案:

I installed gcc-4.8 (and 4.7), and tried to use the symlinks-in-/usr/local/cuda/bin solution suggested here:

CUDA与我的gcc版本不兼容

但这不起作用。我应该怎么办?

but this doesn't work. What should I do?

推荐答案

此解决方案与CUDA和GCC版本的多种组合相关。

您可以告诉CUDA的 nvcc 使用特定版本gcc。你运行:

You can tell CUDA's nvcc to use a specific version of gcc. So, suppose you want gcc 4.7 for use with CUDA 6. You run:

sudo apt-get install gcc-4.7 g++-4.7

,然后将以下开关添加到您的 nvcc 命令行:

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

如果您正在使用CMake构建,请在找到CUDA之前添加适当的设置, c $ c> CMakeLists.txt ,例如:

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)

CUDA,也许这是值得尝试的(虽然你必须适当地构建它)。

Also, it seems clang can compile CUDA as well, maybe that's worth experimenting with (although you would have to build it appropriately).

注意 gcc的多个版本的软件包(在同一版本的发行版中)。我建议反对尝试从另一个版本的发行版强制安装一个包,并考虑构建gcc。这不是微不足道,但它是很可行 - 当然,唯一的选择,如果你不是根。

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版本X抱怨不支持gcc版本Y - 该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆