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

查看:34
本文介绍了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),并尝试使用此处建议的 symlinks-in-/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.因此,假设您希望 gcc 4.7 与 CUDA 6 一起使用.您运行:

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 查找到您的 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)

此外,clang 似乎也可以编译 CUDA,也许这值得一试(尽管您必须适当地构建它).

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

注意:某些 Linux(或其他操作系统)发行版没有适用于多个 gcc 版本的软件包(在同一发行版的操作系统发行版中).我建议不要尝试在旧版本上安装来自另一个发行版的软件包,而是考虑构建 gcc.这并不完全是微不足道的,但它 相当可行 - 当然,如果你不这样做,这是你唯一的选择'对您的机器没有 root 访问权限.

Note: Some Linux (or other OS) distributions don't have packages for multiple versions of gcc (in the same release of the OS distribution). I would advise against trying to install a package from another release of the distribution on an older release, and consider building gcc instead. That's not entirely trivial but it is quite doable - and of course, it's your only option if you don't have root access to your machine.

这篇关于CUDA 版本 X 抱怨不支持 gcc 版本 Y - 怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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