首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >nvcc无法编译

nvcc无法编译
EN

Stack Overflow用户
提问于 2013-06-22 21:31:38
回答 4查看 7.5K关注 0票数 2

我已经在我的pc上安装了CUDA工具包,但似乎有什么东西坏了。nvcc无法编译,也无法编译像这样的简单hello-world:

代码语言:javascript
复制
#include <stdio.h>

int main(int argc, char** argv) {
    printf("Hello, world!\n");
    return 0;
}

输出为:

代码语言:javascript
复制
$ nvcc hello.cu 
/usr/include/c++/4.8.0/cstdlib(178): error: identifier "__int128" is undefined
/usr/include/c++/4.8.0/cstdlib(179): error: identifier "__int128" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_000011a2_00000000-6_hello.cpp1.ii".

详细输出为:

代码语言:javascript
复制
$ nvcc --verbose hello.cu 
#$ _SPACE_= 
#$ _CUDART_=cudart
#$ _HERE_=/opt/cuda/bin
#$ _THERE_=/opt/cuda/bin
#$ _TARGET_SIZE_=64
#$ TOP=/opt/cuda/bin/..
#$ LD_LIBRARY_PATH=/opt/cuda/bin/../lib:
#$ PATH=/opt/cuda/bin/../open64/bin:/opt/cuda/bin/../nvvm:/opt/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/android-sdk/platform-tools:/opt/android-sdk/tools:/opt/android-studio/bin:/opt/cuda/bin:/extra/usr/bin:/opt/java/bin:/opt/java/db/bin:/opt/java/jre/bin:/usr/bin/core_perl:/usr/lib/smlnj/bin:.:.
#$ INCLUDES="-I/opt/cuda/bin/../include"  
#$ LIBRARIES=  "-L/opt/cuda/bin/../lib64" -lcudart
#$ CUDAFE_FLAGS=
#$ OPENCC_FLAGS=
#$ PTXAS_FLAGS=
#$ gcc -D__CUDA_ARCH__=100 -E -x c++    -DCUDA_FLOAT_MATH_FUNCTIONS -DCUDA_NO_SM_11_ATOMIC_INTRINSICS -DCUDA_NO_SM_12_ATOMIC_INTRINSICS -DCUDA_NO_SM_13_DOUBLE_INTRINSICS  -D__CUDACC__ -D__NVCC__  "-I/opt/cuda/bin/../include"   -include "cuda_runtime.h" -m64 -o "/tmp/tmpxft_000011e1_00000000-6_hello.cpp1.ii" "hello.cu" 
#$ cudafe --m64 --gnu_version=40800 -tused --no_remove_unneeded_entities  --gen_c_file_name "/tmp/tmpxft_000011e1_00000000-3_hello.cudafe1.c" --stub_file_name "/tmp/tmpxft_000011e1_00000000-3_hello.cudafe1.stub.c" --gen_device_file_name "/tmp/tmpxft_000011e1_00000000-3_hello.cudafe1.gpu" --nv_arch "compute_10" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_000011e1_00000000-2_hello.module_id" --include_file_name "tmpxft_000011e1_00000000-1_hello.fatbin.c" "/tmp/tmpxft_000011e1_00000000-6_hello.cpp1.ii" 
/usr/include/c++/4.8.0/cstdlib(178): error: identifier "__int128" is undefined

/usr/include/c++/4.8.0/cstdlib(179): error: identifier "__int128" is undefined

2 errors detected in the compilation of "/tmp/tmpxft_000011e1_00000000-6_hello.cpp1.ii".
# --error 0x2 --

关于我的系统的一些信息:

操作系统是Chakra Linux (一个基于Arch的发行版) 64位。目前我使用的是gcc-multilib版本:

代码语言:javascript
复制
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /chakra/lib32-testing/gcc-multilib/src/gcc-4.8-20130411/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://chakra-project.org/bugs --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-gnu-unique-object --enable-linker-build-id --enable-cloog-backend=isl --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-install-libiberty --enable-multilib --disable-libssp --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.0 20130411 (prerelease) (GCC) 

CUDA工具包相关信息:

代码语言:javascript
复制
$ nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2012 NVIDIA Corporation
Built on Fri_Sep_21_17:28:58_PDT_2012
Cuda compilation tools, release 5.0, V0.2.1221

最后但并非最不重要的是,这是有问题的头文件:http://pastebin.com/WtUckrYv

提前谢谢你。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-06-22 21:44:52

CUDA 5.0与gcc 4.8.0不兼容。

有关兼容发行版和gcc版本的更多了解,请参阅release notes

你使用cuda可能会更走运,但是你提到的那个发行版以及你提到的那个gcc版本仍然没有列在5.5 RC支持下的release notes中。

最好的体验很可能是通过切换到支持的发行版来找到的。

通常,CUDA5中的nvcc会自动包含文件/usr/local/cuda/include/host_config.h,该文件包含用于检查正确/可接受的编译器版本的各种宏,在您的情况下,这些宏中的一个应该会抛出错误,但似乎没有:

代码语言:javascript
复制
#if defined(__GNUC__)

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

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

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

#endif /* __GNUC__ */
票数 9
EN

Stack Overflow用户

发布于 2014-05-13 03:45:29

在我的例子中,只有当我尝试使用llvm作为后端进行编译时,才会出现错误,即:

代码语言:javascript
复制
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu

因此,在查看了上面提到的标题后,我添加了:

代码语言:javascript
复制
-D__STRICT_ANSI__

因此,最终的编译命令如下所示:

代码语言:javascript
复制
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu -D__STRICT_ANSI__

我看了一下clang dev论坛,它看起来像是一个已知的问题,但我并没有深入研究。

希望这能有所帮助。

票数 2
EN

Stack Overflow用户

发布于 2013-11-22 14:54:09

如果你在使用gcc-4.7+甚至cuda-5.5的时候遇到了问题,检查一下你是否也安装了旧版本的nvidia-cuda-toolkit,我清除了所有nvdia-cuda-*的东西,它在cuda-5.5上运行得很好(我有gcc-4.8.1)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17251316

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档