SSCNet环境搭建

来源:互联网 发布:数据库内找账号密码 编辑:程序博客网 时间:2024/06/13 22:57

自己留着,省着忘了
配置Semantic Scene Completion from a Single Depth Image http://sscnet.cs.princeton.edu/

硬件:GPU Quadro M6000 24G

最开始配置了caffe+CUDA8.0+cuDNN6.0+Anaconda2+python2.7
http://www.cnblogs.com/zhbzz2007/p/5499180.html
http://blog.csdn.net/u012604811/article/details/53791222

install anaconda2
http://blog.csdn.net/c406495762/article/details/65449495?locationNum=2&fps=1

Matlab配置
http://blog.csdn.net/lcx543576178/article/details/51376008

然后发现cuDNN版本过新,会报一些参数过少的错误,cuDNN版本改成了“cudnn-8.0-linux-x64-v5.1.tgz”

然后开始了无知的爬坑之旅……
开始不了解,以为自己配置好了cafee,SSCNet给的caffe3d_suncg就不需要管它了……
结果
WARNING: Logging before InitGoogleLogging() is written to STDERR
W0522 11:41:47.128919 31334 _caffe.cpp:139] DEPRECATION WARNING - deprecated use of Python interface
W0522 11:41:47.128947 31334 _caffe.cpp:140] Use this instead (with the named "weights" parameter):
W0522 11:41:47.128952 31334 _caffe.cpp:142] Net('demo.txt', 1, weights='../models/suncg_ft_nyu.caffemodel')
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 7:20: Message type "caffe.LayerParameter" has no field named "suncg_data_param".
F0522 11:41:47.130220 31334 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: demo.txt
*** Check failure stack trace: ***
Aborted (core dumped)

发现问题是,可能并不需要自己编译caffe,而是直接编译作者给的caffe_code即可。
开始想把作者对层的定义和参数复制到源生caffe中,后来放弃。

第二个坑出现了,死活编译不过,错误如下:

In file included from /usr/include/c++/4.8/future:35:0, from /home/mobilear/sscnet/caffe_code/caffe3d_suncg/include/caffe/layers/suncg_data_layer.hpp:4, from /home/mobilear/sscnet/caffe_code/caffe3d_suncg/src/caffe/layers/suncg_data_layer.cu:5: /usr/include/c++/4.8/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. #error This file requires compiler and library support for the \ ^ CMake Error at cuda_compile_generated_suncg_data_layer.cu.o.cmake:206 (message): Error generating /home/mobilear/sscnet/caffe_code/caffe3d_suncg/src/caffe/CMakeFiles/cuda_compile.dir/layers/./cuda_compile_generated_suncg_data_layer.cu.o

然后我在CMakeList.txt中加入

list(APPEND CUDA_NVCC_FLAGS "-arch=sm_20;-std=c++11;-O2;-DVERBOSE") SET(CUDA_PROPAGATE_HOST_FLAGS OFF)

接着报错:

[ 1%] Built target proto[ 1%] Building NVCC (Device) object src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined/usr/lib/gcc/x86_64-linux-gnu/4.8/include/stddef.h(432): error: expected a ";"/usr/include/x86_64-linux-gnu/c++/4.8/bits/c++config.h(190): error: expected a ";"/usr/include/c++/4.8/exception(63): error: expected a ";"/usr/include/c++/4.8/exception(68): error: expected a ";"/usr/include/c++/4.8/exception(76): error: expected a ";"/usr/include/c++/4.8/exception(83): error: expected a ";"/usr/include/c++/4.8/exception(93): error: expected a "{"/usr/include/c++/4.8/bits/exception_ptr.h(64): error: function "std::current_exception" returns incomplete type "std::__exception_ptr::exception_ptr"/usr/include/c++/4.8/bits/exception_ptr.h(64): error: expected a "{"/usr/include/c++/4.8/bits/exception_ptr.h(79): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(81): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(82): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(84): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(86): error: declaration is incompatible with previous "std::current_exception"(64): here/usr/include/c++/4.8/bits/exception_ptr.h(86): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(86): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(87): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(90): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(92): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(95): error: incomplete type is not allowed/usr/include/c++/4.8/bits/exception_ptr.h(95): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(116): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(126): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(143): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(144): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(147): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(152): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(153): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(156): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(157): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(160): error: use of a local type to declare a function/usr/include/c++/4.8/bits/exception_ptr.h(161): error: expected a ";"/usr/include/c++/4.8/bits/exception_ptr.h(169): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(57): error: incomplete type is not allowed/usr/include/c++/4.8/bits/nested_exception.h(60): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(66): error: expected a ";"/usr/include/c++/4.8/bits/nested_exception.h(70): error: identifier "rethrow_exception" is undefined/usr/include/c++/4.8/bits/nested_exception.h(73): error: function "std::nested_exception::nested_ptr" returns incomplete type "std::__exception_ptr::exception_ptr"/usr/include/c++/4.8/new(95): error: expected a "{"/usr/include/c++/4.8/new(110): error: identifier "__p" is undefined/usr/include/c++/4.8/new(111): error: expected a "{"/usr/include/c++/4.8/new(115): error: expected a "{"/usr/include/c++/4.8/new(116): error: expected a "{"/usr/local/cuda/include/common_functions.h(106): warning: exception specification is incompatible with that of previous function "operator new[](std::size_t, void *)"/usr/include/c++/4.8/new(111): here/usr/local/cuda/include/common_functions.h(107): warning: exception specification is incompatible with that of previous function "operator delete(void *, void *)"/usr/include/c++/4.8/new(115): here/usr/local/cuda/include/common_functions.h(108): warning: exception specification is incompatible with that of previous function "operator delete[](void *, void *)"/usr/include/c++/4.8/new(116): here/usr/include/c++/4.8/bits/cpp_type_traits.h(184): error: identifier "char16_t" is undefined/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: identifier "char32_t" is undefined/usr/include/c++/4.8/bits/cpp_type_traits.h(191): error: class "std::__is_integer<>" has already been defined/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: namespace "std::__gnu_cxx" has no member "__normal_iterator"/usr/include/c++/4.8/bits/cpp_type_traits.h(314): error: expected a ">"/usr/include/c++/4.8/cmath(80): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(80): error: expected a ";"/usr/include/c++/4.8/cmath(105): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(105): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(105): error: expected a ";"/usr/include/c++/4.8/cmath(124): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(124): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(124): error: expected a ";"/usr/include/c++/4.8/cmath(143): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(143): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(143): error: expected a ";"/usr/include/c++/4.8/cmath(162): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(162): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(162): error: expected a ";"/usr/include/c++/4.8/cmath(183): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(183): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(183): error: expected a ";"/usr/include/c++/4.8/cmath(202): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(202): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(202): error: expected a ";"/usr/include/c++/4.8/cmath(221): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(221): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(221): error: expected a ";"/usr/include/c++/4.8/cmath(240): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(240): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(240): error: expected a ";"/usr/include/c++/4.8/cmath(259): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(259): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(259): error: expected a ";"/usr/include/c++/4.8/cmath(278): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(278): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(278): error: expected a ";"/usr/include/c++/4.8/cmath(297): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(297): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(297): error: expected a ";"/usr/include/c++/4.8/cmath(328): error: "constexpr" is not a function or static data member/usr/include/c++/4.8/cmath(337): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(337): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(337): error: expected a ";"/usr/include/c++/4.8/cmath(356): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(356): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(356): error: expected a ";"/usr/include/c++/4.8/cmath(375): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(375): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(375): error: expected a ";"/usr/include/c++/4.8/cmath(406): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(406): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(406): error: expected a ";"/usr/include/c++/4.8/cmath(443): error: inline specifier allowed on function declarations only/usr/include/c++/4.8/cmath(443): error: variable "std::constexpr" has already been defined/usr/include/c++/4.8/cmath(443): error: expected a ";"Error limit reached.100 errors detected in the compilation of "/tmp/tmpxft_00008230_00000000-7_math_functions.cpp1.ii".Compilation terminated.CMake Error at cuda_compile_generated_math_functions.cu.o.cmake:264 (message):Error generating file/home/mobilear/sscnet/caffe_code/caffe3d_suncg/src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.omake[2]: *** [src/caffe/CMakeFiles/cuda_compile.dir/util/./cuda_compile_generated_math_functions.cu.o] Error 1make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2make: *** [all] Error 2

百思不得其解

最后发现,需要在caffe的源CMakeList.txt中改即可,而不是在src中的CMakeList.txt
相对路径: sscnet/caffe_code/caffe3d_suncg/CMakeList.txt
位置在include(cmake/Dependencies.cmake)后面即可,改后的CMakeList.txt为:

cmake_minimum_required(VERSION 2.8.7)if(POLICY CMP0046)  cmake_policy(SET CMP0046 NEW)endif()if(POLICY CMP0054)  cmake_policy(SET CMP0054 NEW)endif()# ---[ Caffe projectproject(Caffe C CXX)# ---[ Caffe versionset(CAFFE_TARGET_VERSION "1.0.0-rc3" CACHE STRING "Caffe logical version")set(CAFFE_TARGET_SOVERSION "1.0.0-rc3" CACHE STRING "Caffe soname version")add_definitions(-DCAFFE_VERSION=${CAFFE_TARGET_VERSION})# ---[ Using cmake scripts and moduleslist(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)include(ExternalProject)include(cmake/Utils.cmake)include(cmake/Targets.cmake)include(cmake/Misc.cmake)include(cmake/Summary.cmake)include(cmake/ConfigGen.cmake)# ---[ Optionscaffe_option(CPU_ONLY  "Build Caffe without CUDA support" OFF) # TODO: rename to USE_CUDAcaffe_option(USE_CUDNN "Build Caffe with cuDNN library support" ON IF NOT CPU_ONLY)caffe_option(BUILD_SHARED_LIBS "Build shared libraries" ON)caffe_option(BUILD_python "Build Python wrapper" ON)set(python_version "2" CACHE STRING "Specify which Python version to use")caffe_option(BUILD_matlab "Build Matlab wrapper" OFF IF UNIX OR APPLE)caffe_option(BUILD_docs   "Build documentation" ON IF UNIX OR APPLE)caffe_option(BUILD_python_layer "Build the Caffe Python layer" ON)caffe_option(USE_OPENCV "Build with OpenCV support" ON)caffe_option(USE_LEVELDB "Build with levelDB" ON)caffe_option(USE_LMDB "Build with lmdb" ON)caffe_option(ALLOW_LMDB_NOLOCK "Allow MDB_NOLOCK when reading LMDB files (only if necessary)" OFF)# ---[ Dependenciesinclude(cmake/Dependencies.cmake)# ---[ Flagsif(UNIX OR APPLE)  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")endif()list(APPEND CUDA_NVCC_FLAGS "-arch=sm_20;-std=c++11;-O2;-DVERBOSE")SET(CUDA_PROPAGATE_HOST_FLAGS OFF)caffe_set_caffe_link()if(USE_libstdcpp)  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")  message("-- Warning: forcing libstdc++ (controlled by USE_libstdcpp option in cmake)")endif()add_definitions(-DGTEST_USE_OWN_TR1_TUPLE)# ---[ Warningscaffe_warnings_disable(CMAKE_CXX_FLAGS -Wno-sign-compare -Wno-uninitialized)# ---[ Config generationconfigure_file(cmake/Templates/caffe_config.h.in "${PROJECT_BINARY_DIR}/caffe_config.h")# ---[ Includesset(Caffe_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)include_directories(${Caffe_INCLUDE_DIR} ${PROJECT_BINARY_DIR})include_directories(BEFORE src) # This is needed for gtest.# ---[ Subdirectoriesadd_subdirectory(src/gtest)add_subdirectory(src/caffe)add_subdirectory(tools)add_subdirectory(examples)add_subdirectory(python)add_subdirectory(matlab)add_subdirectory(docs)# ---[ Linter targetadd_custom_target(lint COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/lint.cmake)# ---[ pytest targetif(BUILD_python)  add_custom_target(pytest COMMAND python${python_version} -m unittest discover -s caffe/test WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/python )  add_dependencies(pytest pycaffe)endif()# ---[ Configuration summarycaffe_print_configuration_summary()# ---[ Export configs generationcaffe_generate_export_configs()

然后报错:

mobilear@mobilear-HP-Z840-Workstation:~/sscnet/demo$ python demotest_model.py Traceback (most recent call last):  File "demotest_model.py", line 9, in <module>    import caffeImportError: No module named caffe

把环境变量路径放到 ~/.bashrc文件中,打开文件
sudo vim ~/.bashrc
在文件下方写入
export PYTHONPATH=~/caffe/python:$PYTHONPATH
上述语句中 “~” 号表示caffe 所在的根目录。
http://blog.csdn.net/u010417185/article/details/53559107

再次出错:
ImportError: No module named google.protobuf.internal
我装的是anaconda2, 解决方法是在其中安装protobuf最新版本
sudo chmod 777 -R anaconda2
conda install protobuf
http://blog.csdn.net/wuzuyu365/article/details/52431062

接下来准备使用自己的RGB-D数据来用网络跑下结果,我看github中有人问这个问题,感觉又会是一个坑=。=期待早出。

原创粉丝点击