新装deepin系统跑通caffe工程

编译问题:

deepin中激活tensorflow环境时出现错误“-bash: activate: No such file or directory”的解决方法。

解决方法:

在终端代开zshrc进行系统路径添加:

#anaconda2
export PATH=$PATH:"/home/fuxueping/anaconda2/bin"

 

参考:https://blog.csdn.net/w1301100424/article/details/82052418

编译问题:

Could NOT find PythonLibs: Found unsuitable version "2.7.15", but required is exact version "2.7.11" (found /usr/lib/x86_64-linux-gnu/libpython2.7.so)
Found PythonInterp: /usr/bin/python3 (found suitable version "3.6.5", minimum required is "3.4") 
Could NOT find PythonLibs: Found unsuitable version "2.7.15", but required is exact version "3.6.5" (found /usr/lib/x86_64-linux-gnu/libpython2.7.so)
Traceback (most recent call last):
  File "", line 1, in 
ModuleNotFoundError: No module named 'numpy'

解决方法:由于系统中的python和conda中的python冲突了;

参考:https://www.cnblogs.com/whu-zeng/p/7636979.html

编译opencv3.1出问题:

In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/src/tbb/pipeline.cpp:21:0:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
Scanning dependencies of target opencv_highgui_pch_dephelp
make[2]: *** [3rdparty/tbb/CMakeFiles/tbb.dir/build.make:245:3rdparty/tbb/CMakeFiles/tbb.dir/tbb43_20141204oss/src/tbb/pipeline.cpp.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:364:3rdparty/tbb/CMakeFiles/tbb.dir/all] 错误 2
make[1]: *** 正在等待未完成的任务....
[  9%] Building CXX object modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/opencv_ts_pch_dephelp.cxx.o
[  9%] Building CXX object modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/opencv_highgui_pch_dephelp.cxx.o
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/imgcodecs/src/precomp.hpp:48,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/imgcodecs/opencv_imgcodecs_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
make[2]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs_pch_dephelp.dir/build.make:72:modules/imgcodecs/CMakeFiles/opencv_imgcodecs_pch_dephelp.dir/opencv_imgcodecs_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:3743:modules/imgcodecs/CMakeFiles/opencv_imgcodecs_pch_dephelp.dir/all] 错误 2
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/src/precomp.hpp:55,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/core/opencv_core_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/imgproc/src/precomp.hpp:50,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/imgproc/opencv_imgproc_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/videoio/src/precomp.hpp:48,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/videoio/opencv_videoio_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
make[2]: *** [modules/imgproc/CMakeFiles/opencv_imgproc_pch_dephelp.dir/build.make:72:modules/imgproc/CMakeFiles/opencv_imgproc_pch_dephelp.dir/opencv_imgproc_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:2114:modules/imgproc/CMakeFiles/opencv_imgproc_pch_dephelp.dir/all] 错误 2
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/test/test_precomp.hpp:17,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/core/opencv_test_core_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
make[2]: *** [modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/build.make:72:modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1333:modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/all] 错误 2
make[2]: *** [modules/videoio/CMakeFiles/opencv_videoio_pch_dephelp.dir/build.make:72:modules/videoio/CMakeFiles/opencv_videoio_pch_dephelp.dir/opencv_videoio_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:4395:modules/videoio/CMakeFiles/opencv_videoio_pch_dephelp.dir/all] 错误 2
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/ts/src/precomp.hpp:2,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/ts/opencv_ts_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
make[2]: *** [modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/build.make:72:modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/opencv_test_core_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:1252:modules/core/CMakeFiles/opencv_test_core_pch_dephelp.dir/all] 错误 2
In file included from /home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/tbb.h:65:0,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/core/include/opencv2/core/private.hpp:65,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/modules/highgui/src/precomp.hpp:48,
                 from /home/fuxueping/sdb/software/opencv_3_1_0/build/modules/highgui/opencv_highgui_pch_dephelp.cxx:1:
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: error: ‘has_trivial_copy_constructor’ is not a member of ‘std’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:74: note: suggested alternative: ‘is_trivially_copy_constructible’
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                                          is_trivially_copy_constructible
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:104: error: expected primary-expression before ‘>’ token
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                        ^
/home/fuxueping/sdb/software/opencv_3_1_0/build/3rdparty/tbb/tbb43_20141204oss/include/tbb/pipeline.h:328:107: error: ‘::value’ has not been declared
 template struct tbb_trivially_copyable { enum { value = std::has_trivial_copy_constructor::value }; };
                                                                                                           ^~~~~
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/build.make:72:modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/opencv_highgui_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:4629:modules/highgui/CMakeFiles/opencv_highgui_pch_dephelp.dir/all] 错误 2
make[2]: *** [modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/build.make:72:modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/opencv_ts_pch_dephelp.cxx.o] 错误 1
make[1]: *** [CMakeFiles/Makefile2:5581:modules/ts/CMakeFiles/opencv_ts_pch_dephelp.dir/all] 错误 2

解决方法:下载了新的opencv,然后编译再也没出问题,它自己会下载tbb;

使用deepin系统后,编译caffe出现的一系列问题:

  • 编译问题:

/usr/local/cuda/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
NVCC src/caffe/layers/euclidean_loss_layer.cu
In file included from /usr/local/cuda/include/host_config.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:78,
                 from :0:
/usr/local/cuda/include/crt/host_config.h:119:2: error: #error -- unsupported GNU version! gcc versions later than 6 are not supported!
 #error -- unsupported GNU version! gcc versions later than 6 are not supported!
  ^~~~~
In file included from /usr/local/cuda/include/common_functions.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:115,
                 from :0:
/usr/include/boost/config/compiler/nvcc.hpp:22:34: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #if !defined(__CUDACC_VER__) || (__CUDACC_VER__ < 70500)
                                  ^
In file included from /usr/local/cuda/include/common_functions.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:115,
                 from :0:
/usr/include/boost/config/compiler/nvcc.hpp:22:34: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #if !defined(__CUDACC_VER__) || (__CUDACC_VER__ < 70500)
                                  ^
make: *** [Makefile:591:.build_release/cuda/src/caffe/layers/euclidean_loss_layer.o] 错误 1
make: *** 正在等待未完成的任务....
make: *** [Makefile:591:.build_release/cuda/src/caffe/layers/crop_layer.o] 错误 1

解决方法:gcc和g++版本太低。根据上面的报错内容,找到文件host_config.h并打开,注释掉里面的版本检查语句:

参考:https://www.jianshu.com/p/74e9c8697372

  • 编译问题:

/usr/include/boost/python/detail/wrap_python.hpp:50:11: fatal error: pyconfig.h: 没有那个文件或目录
 # include 
           ^~~~~~~~~~~~

解决方法:编译前,执行命名行:

export CPLUS_INCLUDE_PATH=/usr/include/python2.7

参考:https://blog.csdn.net/u010900574/article/details/52877346

  • 查看电脑中的boost版本:

dpkg -S /usr/include/boost/version.hpp

删除现有的boost,使用sudo apt-get autoremove XX 

注意XX代表要删除的boost版本名称;

  • 编译问题:

/usr/include/boost/config/compiler/nvcc.hpp:22:34: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #if !defined(__CUDACC_VER__) || (__CUDACC_VER__ < 70500)
                                  ^
make: *** [Makefile:591:.build_release/cuda/src/caffe/layers/crop_layer.o] 错误 1
make: *** 正在等待未完成的任务....
In file included from /usr/local/cuda/include/common_functions.h:50:0,
                 from /usr/local/cuda/include/cuda_runtime.h:115,
                 from :0:
/usr/include/boost/config/compiler/nvcc.hpp:22:34: error: token ""__CUDACC_VER__ is no longer supported.  Use __CUDACC_VER_MAJOR__, __CUDACC_VER_MINOR__, and __CUDACC_VER_BUILD__ instead."" is not valid in preprocessor expressions
 #if !defined(__CUDACC_VER__) || (__CUDACC_VER__ < 70500)
                                  ^
make: *** [Makefile:591:.build_release/cuda/src/caffe/layers/euclidean_loss_layer.o] 错误 1

参考:boost版本太低,需要对boost版本升级,答案参考:https://blog.csdn.net/seekforcode/article/details/83503791

boost下载链接:https://www.boost.org/users/history/version_1_69_0.html

boost安装编译参考:http://www.cnblogs.com/smallredness/p/9245127.html 

编译问题:

/usr/bin/ld: 找不到 -lboost_python3
/usr/bin/ld: 找不到 -lpython3.5m
collect2: error: ld returned 1 exit status
make: *** [Makefile:569:.build_release/lib/libcaffe.so.1.0.0-rc3] 错误 1

上面这个问题产生的复杂,我的本意是要使用系统中的python2.7版本,这个错报的完全暴露电脑没有去找这个库;处理这个问题操作:

step1:修改caffe中makefile.config中的python路径配置,若路径正确,就往下步走;

step2:在终端输入:

python

            这步的意义就是确定系统默认找的是哪里的python,我在查找过程中发现发现电脑系统中默认是找的conda中的python,那我该怎样修改了,修改系统环境中的内容,之前我犯了两个错,1)把系统的python路径还加载在了bashrc中,这句需要屏蔽掉;2)将conda路径加入bashrc的方式有问题(为什么要将conda加入到系统环境中,原因是如果我不加入的话,conda中的虚拟环境无法激活),修正过来是这样的:export PATH=$PATH:"/home/fuxueping/anaconda2/bin";3)然后在终端再输入“python”就可以查到正确python版本,如果还是conda中的python,输入“python”命名后,可以看到输出有“anconda”字样;

编译问题:

/usr/bin/ld:找不到 -lboost_python

解决问题的方法:该问题还是找不到libboost_python.so,这个问题是由于我的系统中的boost库是我自己编译的,所以python2.7没有生成libboost_python的文件,所以这时候就需要我自己使用boost去编译,具体的编译参考:https://blog.csdn.net/bodybo/article/details/79962814(注意,先把系统的python换成生成libboost_python的python版本,多次实践得来的经验)

注意修改路径,同时最后的软连接是链接到libboost_python.so.

后续:自己要使用python3.6的libboost_pyhton3.so,但是执行了几遍都没有成功;最终解决:将系统默认的python转化为python 3.6版本,再运行就没有问题了。https://blog.csdn.net/bodybo/article/details/79962814第一句话“./bootstrap.sh --with-libraries=python --with-toolset=gcc”反应了boost找到的python版本;

编译问题(截取部分问题):

./include/caffe/proto/caffe.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include 
                                          ^
compilation terminated.
make: *** [Makefile:578:.build_release/src/caffe/layers/mvn_layer.o] 错误 1
make: *** 正在等待未完成的任务....
In file included from src/caffe/layers/data_layer.cpp:8:0:
./include/caffe/data_transformer.hpp:6:44: fatal error: google/protobuf/repeated_field.h: 没有那个文件或目录
 #include "google/protobuf/repeated_field.h"
                                            ^
compilation terminated.
make: *** [Makefile:578:.build_release/src/caffe/layers/data_layer.o] 错误 1
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./include/caffe/layers/sigmoid_cross_entropy_loss_layer.hpp:6,
                 from src/caffe/layers/sigmoid_cross_entropy_loss_layer.cpp:4:
.build_release/src/caffe/proto/caffe.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include 
                                          ^
compilation terminated.
make: *** [Makefile:578:.build_release/src/caffe/layers/sigmoid_cross_entropy_loss_layer.o] 错误 1
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./include/caffe/layers/smooth_L1_loss_layer.hpp:14,
                 from src/caffe/layers/smooth_L1_loss_layer.cpp:11:
.build_release/src/caffe/proto/caffe.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include 
                                          ^
compilation terminated.
make: *** [Makefile:578:.build_release/src/caffe/layers/smooth_L1_loss_layer.o] 错误 1
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./include/caffe/layers/batch_reindex_layer.hpp:7,
                 from src/caffe/layers/batch_reindex_layer.cpp:3:
.build_release/src/caffe/proto/caffe.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include 
                                          ^
compilation terminated.
make: *** [Makefile:578:.build_release/src/caffe/layers/batch_reindex_layer.o] 错误 1
In file included from ./include/caffe/blob.hpp:9:0,
                 from ./include/caffe/filler.hpp:10,
                 from src/caffe/layers/scale_layer.cpp:4:
.build_release/src/caffe/proto/caffe.pb.h:9:42: fatal error: google/protobuf/stubs/common.h: 没有那个文件或目录
 #include 
                                          ^

解决方法:首先查看protobuf的版本,额嗯,由于caffe没有爸爸了,所以它使用的brotobuf版本较低,如果你电脑中的版本较高,可以将其先进行卸载,卸载命名行:

sudo apt-get autoremove libprotobuf-dev 

查看protobuf版本的方法:

protoc --version

删除protobuf

1、用命令找到安装目录

which protoc

2、删除安装目录的安装包,例如下面的命令:

rm /usr/local/bin/protoc

参考:https://blog.csdn.net/jzw230726/article/details/80996922

编译报错:

使用编译好的caffe进行训练:

../../../build/tools/caffe: symbol lookup error:
 /home/fuxueping/sdb/Caffe_Project_Train/caffe-
ssd2/.build_release/tools/../lib/libcaffe.so.1.0.0-rc3: undefined symbol: 
_ZNK6google8protobuf7Message11GetTypeNameB5cxx11Ev

解决方法:

网上说是由于protobuf版本太低,参考:https://blog.csdn.net/yukaixuan520/article/details/81030608,所以对protobuf进行了卸载和重装;

但真实原因是由于电脑中安装了多个版本的brotobuf;这个原因也会在编译的时候报这个错误:

caffe.pb.h:17:2: 错误:#error This file was generated by an older version of protoc

如何确定有没有多版本冲突的问题,可以通过使用cmake-gui来编译caffe,查看protobuf的链接路径来解决:

新装deepin系统跑通caffe工程_第1张图片

上面的路径都是我重新填写的路径,当前路径是正确的;

同时protobuf的路径要在cmake文件夹下的ProtoBuf.cmake中进行重新填写,填写后是这样的(填写的两句是set开头的两句):

新装deepin系统跑通caffe工程_第2张图片

后续报错:

//usr/lib/libboost_python.so:对‘PyUnicodeUCS4_FromEncodedObject’未定义的引用
//usr/lib/libboost_python.so:对‘PyNumber_InPlaceDivide’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_Size’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_FromStringAndSize’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_InternFromString’未定义的引用
//usr/lib/libboost_python.so:对‘PyInt_AsLong’未定义的引用
//usr/lib/libboost_python.so:对‘PyUnicodeUCS4_AsWideChar’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_AsString’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_FromFormat’未定义的引用
//usr/lib/libboost_python.so:对‘PyClass_Type’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_FromString’未定义的引用
//usr/lib/libboost_python.so:对‘PyFile_AsFile’未定义的引用
//usr/lib/libboost_python.so:对‘Py_InitModule4_64’未定义的引用
//usr/lib/libboost_python.so:对‘PyInt_Type’未定义的引用
//usr/lib/libboost_python.so:对‘PyInt_FromLong’未定义的引用
//usr/lib/libboost_python.so:对‘PyFile_FromString’未定义的引用
//usr/lib/libboost_python.so:对‘PyNumber_Divide’未定义的引用
//usr/lib/libboost_python.so:对‘PyString_Type’未定义的引用
collect2: 错误:ld 返回 1
make[2]: *** [tools/CMakeFiles/caffe.bin.dir/build.make:126:tools/caffe] 错误 1
make[1]: *** [CMakeFiles/Makefile2:592:tools/CMakeFiles/caffe.bin.dir/all] 错误 2
make: *** [Makefile:130:all] 错误 2

报错原因是:libboost_python.so是python2.7生成的,而现在我使用的是python3.6;,所以需要对cmake中的boost中内容进行修改; 

你可能感兴趣的:(caffe,deepin)