Caffe编译失败,原因是不支持的gcc编译器版本 [英] Caffe compilation fails due to unsupported gcc compiler version

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

问题描述

我遇到了 Caffe 汇编。很遗憾,我无法编译它。



步骤我遵循:

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

运行使所有失败,并显示以下错误消息:

  [2%]构建NVCC(设备)对象src / caffe / CMakeFiles / cuda_compile.dir / util / cuda_compile_generated_im2col.cu.o 
在/usr/include/cuda_runtime.h:59:0中包含的文件中,
来自< command-line>:0:
/usr/include/host_config.h:82:2:error: #error - 不受支持的GNU版本! gcc 4.9及以上不支持!
#error - 不受支持的GNU版本! gcc 4.9及以上不支持!
^
CMake在cuda_compile_generated_im2col.cu.o.cmake错误:207(消息):
生成/mydir/caffe/build/src/caffe/CMakeFiles/cuda_compile.dir/util/时出错./cuda_compile_generated_im2col.cu.o

软件版本:




  • 操作系统: Debian

  • gcc version: 5.3.1

  • nvcc code> 6.5.12 。

  • cat / proc / driver / nvidia / version result :



  NVRM版本:NVIDIA UNIX x86_64内核模块352.63六Nov 7 21:25:42 PST 2015 
GCC版本:gcc版本4.8.5(Debian 4.8.5-3)






尝试解决问题



第一次尝试 h3>

简单的解决方案通常是最好的解决方案,因此(建议 gcc 版本从 / usr / include / host_config.h (第82行)。不幸的是它不工作和编译失败严重:

 在编译中检测到1个灾难性错误/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii。 



第二次尝试



我试图执行:

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

但是它会与完全错误即使 g ++ - 4.8 应该被接受。)



第三次尝试 >

我找到了类似问题(虽然与 Caffe 不相关),我试图按照接受的答案中的建议解决它。



我做了什么:


  1. 我跑了 grep -iRfind_package CUDAcaffe 命令,并找到 Cuda.cmake find_package(CUDA 5.5 QUIET) .com / BVLC / caffe / blob / master / cmake / Cuda.cmake#L225rel =nofollow> 225 $ set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8) Cuda.cmake ,行前: find_package(CUDA 5.5 QUIET) li>
  2. 我从 build 目录中删除了所有内容,并运行了 cmake make 再次 - 包含和不包含 -D CMAKE_CXX_COMPILER = g ++ - 4.8

不幸的是,结果是完全一样的。



make VERBOSE = 1 2>& ; 1 | grep -i compiler-bindir 不返回任何内容。



有趣的是, make VERBOSE = 1 prints命令失败,这是:

  / 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 / numpy / core / include -I / mydir / caffe / include -I / mydir / caffe / build 

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

  nvcc fatal:redefinition of argument'compiler-bindir'

这可能与错误报告相关。



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






我如何成功完成我的编译?任何帮助。



相关问题:




解决方案 / div>

cmake -D CUDA_NVCC_FLAGS = - ccbin gcc-4.8...&&&&< / code>导致成功编译 / p>




现在出现了另一个问题:链接Google的 libgflags c $ c> libprotobuf 失败可能是因为它是用新的 gcc 版本编译的,但它与提问问题无关。

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

Steps I followed:

git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
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

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


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

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

3rd try

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

What I did:

  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.

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

make VERBOSE=1 2>&1 | grep -i compiler-bindir returns nothing.

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

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

nvcc fatal   : redefinition of argument 'compiler-bindir'

which may be related to this bug report.

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

Related SO questions:

解决方案

cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make causes successful compilation.


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.

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

查看全文

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