I struggle with Caffe compilation. Unfortunately I failed to compile it.
我对Caffe编译感到困惑。不幸的是,我没有编译它。
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
. - 操作系统:Debian。
-
gcc
version:5.3.1
. - gcc版本:5.3.1。
-
nvcc
version:6.5.12
. - 学校网站版本:6.5.12。
-
cat /proc/driver/nvidia/version
result: - 猫/proc/driver/nvidia/version结果:
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:
简单的解决方案通常是最好的解决方案,因此(如本文所建议的)我尝试从/usr/include/host_config注释掉gcc的宏检查gcc版本。h(第82行)。不幸的是,它不起作用,编译失败严重:
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).
但是,它在错误消息上失败了(即使应该接受g+ -4.8)。
3rd try
I've found similar problem (though not related to Caffe) and I tried to solve it as suggested in the accepted answer.
我发现了类似的问题(虽然和Caffe没有关系),我试图按照公认的答案解决它。
What I did:
我所做的:
- I've ran
grep -iR "find_package(CUDA" caffe
command and foundCuda.cmake
file which hasfind_package(CUDA 5.5 QUIET)
in line 225. - 我运行了grep -iR“find_package”(CUDA) caffe命令并找到了CUDA。cmake文件,在225行有find_package(CUDA 5.5 QUIET)。
- I added
set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8)
toCuda.cmake
, line before line:find_package(CUDA 5.5 QUIET)
. - 我向Cuda添加了set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8)。cmake,行前行:find_package(CUDA 5.5 QUIET)。
- I removed everything from
build
directory and rancmake
andmake
again - with and without-D CMAKE_CXX_COMPILER=g++-4.8
. - 我从build目录中删除了所有内容,并运行了cmake和make——有和没有- 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.
不幸的是,结果完全相同。Caffe可能以某种方式重写了它——我没有弄明白它是如何实现的。
make VERBOSE=1 2>&1 | grep -i compiler-bindir
returns nothing.
使VERBOSE=1 2>和1 | grep -i编译器-bindir不返回任何内容。
What's interesting, make VERBOSE=1
prints command that fails, which is:
有趣的是,令VERBOSE=1打印失败的命令,即:
/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:
当我手动添加——编译器-bindir /usr/bin/gcc-4.8标志时,它打印错误:
nvcc fatal : redefinition of argument 'compiler-bindir'
which may be related to this bug report.
这可能与这个bug报告有关。
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.
编辑:我没有注意到——编译器-bindir和-ccbin是相同的选项,后者已经在上面的命令中设置为failed。当我在上面的命令中将-ccbin /usr/bin/cc更改为-ccbin /usr/bin/gcc-4.8失败时,它成功地完成了。现在我需要在Caffe的CMake文件中找到在所有后续的Caffe的CMake中覆盖-ccbin的选项。看着cmake / Cuda。cmake:252:列表(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA}似乎是不错的方法。
How can I successfully complete my compilation? Any help is appreciated.
我怎样才能成功地完成我的汇编?任何帮助都是感激。
Related SO questions:
相关问题:
- host_config.h:unsupported GNU version! gcc versions later than 4.9 are not supported.
- host_config。h:不支持的GNU版本!不支持小于4.9的gcc版本。
- CUDA 6.5 complains about not supporting gcc 4.9 - what to do?.
- CUDA 6.5抱怨不支持gcc 4.9 -怎么办?
2 个解决方案
#1
6
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make
causes successful compilation.
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .成功的编译。
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.
现在另一个问题出现了:连接谷歌的libgflags或libprotobuf失败可能是因为它是用新的gcc版本编译的,但它与被询问的问题无关。
#2
1
My machine runs Ubuntu 15.10, and my default compiler version is gcc 5.2.1 .
我的机器运行Ubuntu 15.10,我的默认编译器版本是gcc 5.2.1。
Commenting out the #error directive in line 115 of file
注释掉文件第115行中的#error指令
/usr/local/cuda-7.5/include/host_config.h
(or whatever the path on your system is) did the trick for me. Caffe compiled fine, all tests ran smoothly.
(或者不管你的系统的路径是什么)为我做了这个魔术。Caffe编译得很好,所有的测试都运行得很顺利。
On the other hand, if one chooses to ignore this and proceed to compile part of the project with one compiler version, part of the project with another (for me it was gcc-4.8 and gcc-5.2.1), linking problems will arise. The linking problems of protobuf and libgflags another answer mentions are not unrelated to this.
另一方面,如果一个人选择忽略这一点,继续使用一个编译器版本编译项目的一部分,使用另一个编译器版本编译项目的一部分(对我来说是gcc-4.8和gcc-5.2.1),就会出现链接问题。另一个问题是protobuf和libgflags的链接问题。
#1
6
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .. && make
causes successful compilation.
cmake -D CUDA_NVCC_FLAGS="-ccbin gcc-4.8" .成功的编译。
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.
现在另一个问题出现了:连接谷歌的libgflags或libprotobuf失败可能是因为它是用新的gcc版本编译的,但它与被询问的问题无关。
#2
1
My machine runs Ubuntu 15.10, and my default compiler version is gcc 5.2.1 .
我的机器运行Ubuntu 15.10,我的默认编译器版本是gcc 5.2.1。
Commenting out the #error directive in line 115 of file
注释掉文件第115行中的#error指令
/usr/local/cuda-7.5/include/host_config.h
(or whatever the path on your system is) did the trick for me. Caffe compiled fine, all tests ran smoothly.
(或者不管你的系统的路径是什么)为我做了这个魔术。Caffe编译得很好,所有的测试都运行得很顺利。
On the other hand, if one chooses to ignore this and proceed to compile part of the project with one compiler version, part of the project with another (for me it was gcc-4.8 and gcc-5.2.1), linking problems will arise. The linking problems of protobuf and libgflags another answer mentions are not unrelated to this.
另一方面,如果一个人选择忽略这一点,继续使用一个编译器版本编译项目的一部分,使用另一个编译器版本编译项目的一部分(对我来说是gcc-4.8和gcc-5.2.1),就会出现链接问题。另一个问题是protobuf和libgflags的链接问题。