我挣扎着Caffe http://caffe.berkeleyvision.org/汇编。不幸的是我没能编译它。
Steps http://caffe.berkeleyvision.org/installation.html#cmake-compilation我跟着:
git clone https://github.com/BVLC/caffe.git
cd caffe
mkdir build
cd build
cmake ..
make all
Running make all
失败并显示以下错误消息:
[ 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
软件版本:
- OS:
Debian
.
-
gcc
版本:5.3.1
.
-
nvcc
版本: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)
尝试解决问题
1st try
简单的解决方案通常是最好的解决方案,所以(按照建议here https://devtalk.nvidia.com/default/topic/516939/cuda4-1-gcc-4-6/)我试图注释掉宏检查gcc
版本来自/usr/include/host_config.h
(第 82 行)。不幸的是它不起作用并且编译严重失败:
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000069c2_00000000-4_im2col.cpp4.ii".
2nd try
我尝试运行:
cmake -D CMAKE_CXX_COMPILER=g++-4.8 ..
make
但它失败了exactly相同的错误消息(即使g++-4.8
应该被接受)。
3rd try
我找到了类似的问题 https://stackoverflow.com/questions/28009785/cuda-6-5-complains-about-not-supporting-gcc-4-9-what-to-do(虽然不相关Caffe),我尝试按照已接受的答案中的建议解决它。
我做了什么:
- 我跑了
grep -iR "find_package(CUDA" caffe
命令并发现Cuda.cmake https://github.com/BVLC/caffe/blob/master/cmake/Cuda.cmake文件有find_package(CUDA 5.5 QUIET)
排队225 https://github.com/BVLC/caffe/blob/master/cmake/Cuda.cmake#L225.
- I added
set(CUDA_HOST_COMPILER /usr/bin/gcc-4.8)
to Cuda.cmake https://github.com/BVLC/caffe/blob/master/cmake/Cuda.cmake,行前行:find_package(CUDA 5.5 QUIET)
.
- 我删除了所有内容
build
目录并运行cmake
and make
再次 - 有和没有-D CMAKE_CXX_COMPILER=g++-4.8
.
不幸的是结果是完全相同的。 Caffe 可能会以某种方式覆盖它 - 我没弄清楚how.
make VERBOSE=1 2>&1 | grep -i compiler-bindir
什么也不返回。
有什么有趣的,make 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
当我添加--compiler-bindir /usr/bin/gcc-4.8
手动标记,它打印错误:
nvcc fatal : redefinition of argument 'compiler-bindir'
这可能与this https://cmake.org/Bug/view.php?id=13674错误报告。
Edit:我没注意到--compiler-bindir
and -ccbin
是相同的选项,并且后者已经在上面失败的命令中设置。当我改变的时候-ccbin /usr/bin/cc
to -ccbin /usr/bin/gcc-4.8
在上面失败的命令中,它成功完成。现在我需要在 Caffe 的 CMake 文件中找到覆盖的选项-ccbin
在所有后续 Caffe 的 CMake 中。看着cmake/Cuda.cmake:252:list(APPEND CUDA_NVCC_FLAGS ${NVCC_FLAGS_EXTRA}
似乎是个好方法。
我怎样才能成功完成我的编译?任何帮助表示赞赏。
相关问题:
- host_config.h:不支持的 GNU 版本!不支持 4.9 之后的 gcc 版本. https://stackoverflow.com/questions/33886654/host-config-hunsupported-gnu-version-gcc-versions-later-than-4-9-are-not-suppo
- CUDA 6.5 抱怨不支持 gcc 4.9 - 该怎么办?. https://stackoverflow.com/questions/28009785/cuda-6-5-complains-about-not-supporting-gcc-4-9-what-to-do