由于 gcc 编译器版本不受支持,Caffe 编译失败 [英] Caffe compilation fails due to unsupported gcc compiler version

查看:39
本文介绍了由于 gcc 编译器版本不受支持,Caffe 编译失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为 Caffe 编译而苦恼.可惜我编译失败了.

I struggle with Caffe compilation. Unfortunately I failed to compile it.

步骤我遵循了:

git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
make all

运行 make all 失败并显示以下错误消息:

Running make all fails with the following error message:

[  2%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o
In file included from /usr/include/cuda_runtime.h:59:0,
                 from <command-line>:0:
/usr/include/host_config.h:82:2: error: #error -- unsupported GNU version! gcc 4.9 and up are not supported!
 #error -- unsupported GNU version! gcc 4.9 and up are not supported!
  ^
CMake Error at cuda_compile_generated_im2col.cu.o.cmake:207 (message):
  Error generating /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_im2col.cu.o

软件版本:

  • 操作系统:Debian.
  • gcc 版本:5.3.1.
  • nvcc 版本:6.5.12.
  • cat/proc/driver/nvidia/version 结果:
  • OS: Debian.
  • gcc version: 5.3.1.
  • nvcc version: 6.5.12.
  • cat /proc/driver/nvidia/version result:
NVRM version: NVIDIA UNIX x86_64 Kernel Module  352.63  Sat Nov  7 21:25:42 PST 2015
GCC version:  gcc version 4.8.5 (Debian 4.8.5-3) 

<小时>

尝试解决问题

第一次尝试

简单的解决方案通常是最好的解决方案,因此(如建议 here) 我试图注释掉 /usr/include/host_config.h 中的宏检查 gcc 版本(第 82 行).不幸的是它不起作用并且编译失败:


Attempts to solve the problem

1st try

Simple solutions are often best ones, so (as suggested here) I tried to comment out macro checking gcc version from /usr/include/host_config.h (line 82). Unfortunately it doesn't work and compilation fails badly:

1 catastrophic error detected in the compilation of "/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii".

第二次尝试

我试着跑了:

2nd try

I tried to run:

cmake -D CMAKE_CXX_COMPILER=g++-4.8 ..
make

但它失败了 exactly 相同的错误消息(即使 g++-4.8 应该被接受).

but it fails with exactly the same error message (even though g++-4.8 should be accepted).

我发现 类似问题(虽然与Caffe无关),我尝试按照接受的答案中的建议解决它.

I've found similar problem (though not related to Caffe) and I tried to solve it as suggested in the accepted answer.

我做了什么:

  1. 我运行了 grep -iR "find_package(CUDA" caffe 命令并找到了 Cuda.cmake 文件在 225.
  2. 我将 set(CUDA_HOST_COMPILER/usr/bin/gcc-4.8) 添加到 Cuda.cmake,行前行:find_package(CUDA 5.5 QUIET).
  3. 我从 build 目录中删除了所有内容并再次运行 cmakemake - 使用和不使用 -D CMAKE_CXX_COMPILER=g++-4.8.
  1. I've ran grep -iR "find_package(CUDA" caffe command and found Cuda.cmake file which has find_package(CUDA 5.5 QUIET) in line 225.
  2. I added set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8) to Cuda.cmake, line before line: find_package(CUDA 5.5 QUIET).
  3. I removed everything from build directory and ran cmake and make again - with and without -D CMAKE_CXX_COMPILER=g++-4.8.

不幸的是结果完全一样.Caffe 可能会以某种方式覆盖它 - 我没有弄清楚如何.

Unfortunately result is exactly the same. Caffe probably overwrites it somehow - I didn't figure it out how.

使 VERBOSE=1 2>&1 |grep -i compiler-bindir 什么都不返回.

有趣的是,make VERBOSE=1 打印失败的命令,即:

What's interesting, make VERBOSE=1 prints command that fails, which is:

/usr/bin/nvcc -M -D__CUDACC__ /mydir/caffe/src/caffe/util/im2col.cu -o /mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/cuda_compile_generated_im2col.cu.o.NVCC-depend -ccbin /usr/bin/cc -m64 -DUSE_LMDB -DUSE_LEVELDB -DUSE_OPENCV -DWITH_PYTHON_LAYER -DGTEST_USE_OWN_TR1_TUPLE -Xcompiler ,"-fPIC","-Wall","-Wno-sign-compare","-Wno-uninitialized","-O3","-DNDEBUG" -gencode arch=compute_20,code=sm_21 -Xcudafe --diag_suppress=cc_clobber_ignored -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=useless_using_declaration -Xcudafe --diag_suppress=set_but_not_used -Xcompiler -fPIC -DNVCC -I/usr/include -I/mydir/caffe/src -I/usr/include -I/mydir/caffe/build/include -I/usr/include/hdf5/serial -I/usr/include/opencv -I/usr/include/atlas -I/usr/include/python2.7 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/mydir/caffe/include -I/mydir/caffe/build

当我手动添加 --compiler-bindir/usr/bin/gcc-4.8 标志时,它会打印错误:

when I add --compiler-bindir /usr/bin/gcc-4.8 flag manually, it prints error:

nvcc fatal   : redefinition of argument 'compiler-bindir'

这可能与 this 错误报告有关.

which may be related to this bug report.

没注意到--compiler-bindir-ccbin是同一个选项,后者已经是在上面的命令中设置失败.当我在上述失败的命令中将 -ccbin/usr/bin/cc 更改为 -ccbin/usr/bin/gcc-4.8 时,它成功完成.现在我需要在 Caffe 的 CMake 文件中找到覆盖所有后续 Caffe 的 CMake 中的 -ccbin 的选项.查看 cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA} 似乎是个好方法.

I didn't notice that --compiler-bindir and -ccbin are the same options, and the latter is already set in above command that failed. When I changed -ccbin /usr/bin/cc to -ccbin /usr/bin/gcc-4.8 in above command that failed, it completes successfully. Now I need to find option in Caffe's CMake file that overwrite -ccbin in all subsequent Caffe's CMakes. Looking at cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA} seems to be good way to go.

我怎样才能成功地完成我的编译?任何帮助表示赞赏.

How can I successfully complete my compilation? Any help is appreciated.

相关的 SO 问题:

推荐答案

cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. &&make 导致编译成功.

现在出现了另一个问题:链接 Google 的 libgflagslibprotobuf 失败可能是因为它是用较新的 gcc 版本编译的,但它是与提出的问题无关.

Now another problem showed up: linking Google's libgflags or libprotobuf fails probably due to fact that it was compiled with newer gcc version but it's not related to asked question.

这篇关于由于 gcc 编译器版本不受支持,Caffe 编译失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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