CUDA 与我的 gcc 版本不兼容 [英] CUDA incompatible with my gcc version

查看:102
本文介绍了CUDA 与我的 gcc 版本不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在编译 CUDA SDK 附带的一些示例时遇到问题.我已经安装了开发者驱动程序(版本 270.41.19)和 CUDA 工具包,最后是SDK(都是4.0.17版本).

I have troubles compiling some of the examples shipped with CUDA SDK. I have installed the developers driver (version 270.41.19) and the CUDA toolkit, then finally the SDK (both the 4.0.17 version).

最初它根本没有编译:

error -- unsupported GNU version! gcc 4.5 and up are not supported!

我在 81:/usr/local/cuda/include/host_config.h 中找到了负责的行,并将其更改为:

I found the line responsible in 81:/usr/local/cuda/include/host_config.h and changed it to:

//#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)

从那时起,我只需要编译几个示例,就停止了:

from that point on I got only a few of the examples to compile, it stops with:

In file included from /usr/include/c++/4.6/x86_64-linux-gnu/bits/gthr.h:162:0,
             from /usr/include/c++/4.6/ext/atomicity.h:34,
             from /usr/include/c++/4.6/bits/ios_base.h:41,
             from /usr/include/c++/4.6/ios:43,
             from /usr/include/c++/4.6/ostream:40,
             from /usr/include/c++/4.6/iterator:64,
             from /usr/local/cuda/include/thrust/iterator/iterator_categories.h:38,
             from /usr/local/cuda/include/thrust/device_ptr.h:26,
             from /usr/local/cuda/include/thrust/device_malloc_allocator.h:27,
             from /usr/local/cuda/include/thrust/device_vector.h:26,
             from lineOfSight.cu:37:
/usr/include/c++/4.6/x86_64-linux-gnu/bits/gthr-default.h:251:1: error: pasting         "__gthrw_" and "/* Android's C library does not provide pthread_cancel, check for
`pthread_create' instead.  */" does not give a valid preprocessing token
make[1]: *** [obj/x86_64/release/lineOfSight.cu.o] Error 1

在编译一些示例时,我认为这不是驱动程序问题,而是与不受支持的 gcc 版本有关.降级不是一个选项,因为此时 gcc4.6 将整个系统作为依赖项...

As some of the examples compile I reckon this is not a driver problem, but rather must have something to do with an unsupported gcc version. Downgrading is not an option as gcc4.6 has a whole system as a dependency at this point...

推荐答案

如前所述,nvcc 依赖于 gcc 4.4.通过将软链接添加到使用 nvcc 安装创建的 bin 目录,可以将 nvcc 配置为使用正确版本的 gcc,而无需传递任何编译器参数.

As already pointed out, nvcc depends on gcc 4.4. It is possible to configure nvcc to use the correct version of gcc without passing any compiler parameters by adding softlinks to the bin directory created with the nvcc install.

默认的cuda二进制目录(安装默认)是/usr/local/cuda/bin,从这个目录添加到正确版本的gcc的软链接就足够了:

The default cuda binary directory (the installation default) is /usr/local/cuda/bin, adding a softlink to the correct version of gcc from this directory is sufficient:

sudo ln -s/usr/bin/gcc-4.4/usr/local/cuda/bin/gcc

这篇关于CUDA 与我的 gcc 版本不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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