Cuda 编译器不适用于 GCC 4.5 + [英] Cuda compiler not working with GCC 4.5 +

查看:22
本文介绍了Cuda 编译器不适用于 GCC 4.5 +的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Cuda 的新手,我正在尝试编译这个简单的 test_1.cu 文件:

I am new to Cuda, and I am trying to compile this simple test_1.cu file:

#include <stdio.h>

__global__ void kernel(void)
{
}

int main (void)
{
    kernel<<<1,1>>>();
    printf( "Hello, World!
");
    return 0;

}

使用这个:nvcc test_1.cu

我得到的输出是:

In file included from /usr/local/cuda/bin/../include/cuda_runtime.h:59:0,
                 from <command-line>:0:
/usr/local/cuda/bin/../include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.5 and up are not supported!

我的 gcc --version:

my gcc --version:

gcc (Ubuntu/Linaro 4.6.1-9ubuntu3) 4.6.1
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

我怎样才能安装 gcc 的第二个版本(4.4 -)以及 4.6 而不会搞砸一切?

How can I install a second version of gcc (4.4 -) along with 4.6 without messing everything up?

我发现了这个老话题:

CUDA 与我的 gcc 版本不兼容

答案是:

CUDA 不支持 gcc 4.5 和 4.6 - 代码无法编译和工具链的其余部分,包括 cuda-gdb,将无法正常工作.你不能使用它们,而且限制是不可协商的.

gcc 4.5 and 4.6 are not supported with CUDA - code won't compile and the rest of the toolchain, including cuda-gdb, won't work properly. You cannot use them, and the restriction is non-negotiable.

您唯一的解决方案是安装 gcc 4.4 版本作为第二个编译器(大多数发行版都允许这样做).有一个选项nvcc --compiler-bindir 可用于指向替代方案编译器.创建一个本地目录并生成指向该目录的符号链接支持 gcc 版本的可执行文件.将该本地目录传递给 nvcc通过 --compiler-bindir 选项,你应该能够编译CUDA 代码而不影响系统的其余部分.

Your only solution is to install a gcc 4.4 version as a second compiler (most distributions will allow that). There is an option to nvcc --compiler-bindir which can be used to point to an alternative compiler. Create a local directory and the make symbolic links to the supported gcc version executables. Pass that local directory to nvcc via the --compiler-bindir option, and you should be able to compile CUDA code without effecting the rest of your system.

但我不知道该怎么做

推荐答案

在网上做一些研究显示了完成此任务的几种方法.我刚刚测试了这里找到的方法:http://www.vectorfabrics.com/blog/item/cuda_4.0_on_ubuntu_11.04 它对我来说就像一个魅力.它引导您安装 gcc 4.4 并创建脚本以使用 nvcc 运行该版本.如果您更喜欢尝试帖子中提到的方法,我建议您按照第一个链接安装 gcc4.4,然后创建帖子中提到的符号链接.在 Linux 中创建符号链接是通过使用 'ln' 命令完成的.

Doing some research online shows several methods for accomplishing this task. I just tested the method found here: http://www.vectorfabrics.com/blog/item/cuda_4.0_on_ubuntu_11.04 and it worked like a charm for me. It steps you through installing gcc 4.4 and creating scripts to run that version with nvcc. If you prefer trying the method mentioned in your post I'd recommend following that first link to install gcc4.4 and then create symbolic links as mentioned in your post. Creating symbolic links in Linux is accomplished by using the 'ln' command.

例如:

 ln -s [source file/folder path] [linkpath]

此链接提供了几个在 Ubuntu 和 Windows 上创建符号链接的示例:http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/.希望这会为您指明正确的方向.

This link gives a few examples of creating symbolic links on both Ubuntu and Windows: http://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/. Hopefully that points you in the right direction.

这篇关于Cuda 编译器不适用于 GCC 4.5 +的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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