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

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

问题描述

编译CUDA SDK附带的一些例子时遇到麻烦。
我已经安装了开发人员驱动程序(版本270.41.19)和CUDA工具包,
然后终于SDK(4.0.17版本)。



最初它没有编译所有给予:

 错误 - 不支持GNU版本!不支持gcc 4.5及以上版本! 

我发现81行负责:/usr/local/cuda/include/host_config.h将其更改为:

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

一些例子要编译,它停止:

 在包含在/usr/include/c++/4.6/x86_64 -linux-gnu / bits / gthr.h:162:0,
来自/usr/include/c++/4.6/ext/atomicity.h:34,
来自/usr/include/c++/4.6 /bits/ios_base.h:41,
来自/usr/include/c++/4.6/ios:43,
来自/usr/include/c++/4.6/ostream:40,
从/usr/include/c++/4.6/iterator:64,
来自/usr/local/cuda/include/thrust/iterator/iterator_categories.h:38,
来自/ usr / local / cuda / include /thrust/device_ptr.h:26,
来自/usr/local/cuda/include/thrust/device_malloc_allocator.h:27,
来自/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_ 和/ * Android的C库不提供pthread_cancel,而是检查
`pthread_create'。 * /没有给出有效的预处理令牌
make [1]:*** [obj / x86_64 / release / lineOfSight.cu.o]错误1
pre>

作为一些例子编译我认为这不是驱动程序的问题,而是必须有一些不支持的gcc版本。降级不是一个选项gcc4.6有一个整个系统作为依赖在这一点...

解决方案

正如已经指出,nvcc依赖于gcc 4.4。通过向使用nvcc install创建的bin目录添加软链接,可以将nvcc配置为使用正确的gcc版本,而不传递任何编译器参数。



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



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


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).

Initially it didn't compile at all giving:

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

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

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...

解决方案

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.

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天全站免登陆