linux – Cuda编译器不使用GCC 4.5

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

#include <stdio.h>

__global__ void kernel(void)
{
}

int main (void)
{
    kernel<<<1,1>>>();
    printf( "Hello, World!\n");
    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:

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而不会搞乱一切?

我找到了这个老话题:

CUDA incompatible with my gcc version

答案是:

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.

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’命令完成的.

例如:

 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/.希望这可以指向正确的方向.

相关文章

ubuntu退出redis的示例:指定配置文件方式启动源码redis:roo...
ubuntu中mysql改密码忘了的解决方法:1.在终端中切换到root权...
ubuntu安装mysql失败的解决方法原因:可能是原有的MySQL还有...
使用centos和ubuntu建站的区别有以下几点1.CentOS是Linux发行...
ubuntu图形界面和字符界面切换的方法:可以通过快捷键CTRL+A...
ubuntu中重启mysql失败的解决方法1.首先,在ubuntu命令行中,...