我在编译CUDA SDK中的一些示例时遇到了问题。 我已经安装了开发者驱动程序(版本270.41.19)和CUDA工具包, 最后安装了SDK(4.0.17版本)。
最初它根本无法编译,会出现以下错误:
error -- unsupported GNU version! gcc 4.5 and up are not supported!
我在81行找到了负责的代码:/usr/local/cuda/include/host_config.h,然后将其修改为:
//#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 4)
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
从那个点开始,我只编译了几个示例,然后就停在了这里:
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作为整个系统的依赖关系...
export TORCH_DONT_CHECK_COMPILER_ABI=1
并重新运行了setup.py,一切都顺利安装。我使用的是CUDA 12.0 g++ 12.x。 - Muneeb Ahmad Khurram