Cuda nvcc无法编译
我已经在我的电脑上安装了CUDA工具包,但有些东西似乎坏了。nvcc无法编译,也无法编译以下简单的hello world:Cuda nvcc无法编译,cuda,nvcc,Cuda,Nvcc,我已经在我的电脑上安装了CUDA工具包,但有些东西似乎坏了。nvcc无法编译,也无法编译以下简单的hello world: #include <stdio.h> int main(int argc, char** argv) { printf("Hello, world!\n"); return 0; } 详细输出为: $ nvcc hello.cu /usr/include/c++/4.8.0/cstdlib(178): error: identifier "
#include <stdio.h>
int main(int argc, char** argv) {
printf("Hello, world!\n");
return 0;
}
详细输出为:
$ 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".
$ 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 --
有关我的系统的一些信息:
该操作系统是基于Arch的64位发行版Chakra Linux。目前我使用的是gcc多库版本:
$ 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工具包的信息:
$ 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
最后但并非最不重要的一点是,这是有问题的头文件:
提前感谢。CUDA 5.0与gcc 4.8.0不兼容 要更好地了解兼容的发行版和gcc版本,请参阅 使用cuda可能会更幸运,但您提到的特定发行版以及gcc版本仍然没有在linux支持下列出 最好的体验很可能是切换到受支持的发行版 通常情况下,CUDA 5中的nvcc将自动包含文件/usr/local/CUDA/include/host_config.h,该文件包含各种宏以检查是否正确/可接受的编译器版本,其中一个宏应该在您的情况下引发错误,但似乎没有:
#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__ */
CUDA 5.0与gcc 4.8.0不兼容 要更好地了解兼容的发行版和gcc版本,请参阅 使用cuda可能会更幸运,但您提到的特定发行版以及gcc版本仍然没有在linux支持下列出 最好的体验很可能是切换到受支持的发行版 通常情况下,CUDA 5中的nvcc将自动包含文件/usr/local/CUDA/include/host_config.h,该文件包含各种宏以检查是否正确/可接受的编译器版本,其中一个宏应该在您的情况下引发错误,但似乎没有:
#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__ */
这是一个至少对我有效的解决方案。我已经安装了cuda 5.0和gcc 4.8 您只需添加:
#undef _GLIBCXX_USE_INT128
just before line #129:
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
在文件/usr/include/c++/4.8.1/cstdlib中
通过这样做,我可以再次编译代码。这是一个至少对我有效的解决方案。我已经安装了cuda 5.0和gcc 4.8 您只需添加:
#undef _GLIBCXX_USE_INT128
just before line #129:
#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_INT128)
在文件/usr/include/c++/4.8.1/cstdlib中
通过这样做,我可以再次编译我的代码。如果您在使用gcc-4.7+甚至cuda-5.5时遇到问题,请检查您是否也安装了旧版本的nvidia cuda toolkit,我清除了所有nvdia cuda-*内容,cuda-5.5运行正常。如果您在使用gcc-4.7+甚至cuda-5.5时遇到问题,我有gcc-4.8.1,检查是否还安装了旧版本的nvidia cuda toolkit,我清除了所有nvdia cuda-*内容,cuda-5.5运行正常。我有gcc-4.8.1,在我的情况下,只有在尝试使用llvm作为后端进行编译时,才会出现错误,即:
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu
因此,在查看上述标题后,我添加了:
-D__STRICT_ANSI__
最后的编译命令如下所示:
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu -D__STRICT_ANSI__
我查看了Clangdev论坛,它看起来是一个已知的问题,但我没有深入挖掘
希望这有帮助。在我的例子中,只有当我尝试使用llvm作为后端进行编译时,错误才会出现,即:
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu
因此,在查看上述标题后,我添加了:
-D__STRICT_ANSI__
最后的编译命令如下所示:
nvcc -ccbin=/usr/bin/clang -arch=sm_20 -m64 main.cu -D__STRICT_ANSI__
我查看了Clangdev论坛,它看起来是一个已知的问题,但我没有深入挖掘
希望这有帮助。哦,这很烦人,但谢谢你。在我的系统中,我没有那个文件,这可能是安装不好的迹象…顺便说一句,我会尝试在Windows上安装CUDA。CUDA 5.5应该支持Visual Studio 2012,对吗?是的,CUDA 5.5应该支持VS2012。为了便于安装,请确保在运行CUDA 5.5安装程序之前在您的计算机上安装了VS2012。当然,CUDA 5.5仍处于RC发行候选阶段,因此目前处于测试阶段。我可以确认,CUDA 5.5和Nsight 3.1在VS 2012上运行良好。直到现在我才遇到任何问题。哦,这很烦人,但谢谢你。在我的系统中,我没有那个文件,这可能是安装不好的迹象…顺便说一句,我会尝试在Windows上安装CUDA。CUDA 5.5应该支持Visual Studio 2012,对吗?是的,CUDA 5.5应该支持VS2012。为了便于安装,请确保在运行CUDA 5.5安装程序之前在您的计算机上安装了VS2012。当然,CUDA 5.5仍处于RC发行候选阶段,因此目前处于测试阶段。我可以确认,CUDA 5.5和Nsight 3.1在VS 2012上运行良好。到目前为止,我还没有遇到任何问题。我从不建议修改系统头,以便让CUDA使用不受支持的编译器版本。编译非CUDA代码时可能出现的问题是巨大的。我决不建议修改系统头以使CUDA使用不受支持的编译器版本。编译非CUDA代码时出现问题的可能性是巨大的。