我是Caffe图书馆的初学者。 我只是在本教程示例中编译和测试代码:https://github.com/DeepLearningStudy/caffe/blob/master/examples/ex4_layer/main.cpp。 我有一个CPU_ONLY构建,所以编译给出了错误的未定义引用`void caffe :: caffe_gpu_dot(int,double const *,double const *,double *)' 。 通过调用函数Forward()发出。 为了完成编译,我修改了argmax层代码并将forward_cpu()作为公共函数成员。
尽管有这条线: 来自Caffe :: SET_MODE(朱古力:: CPU) 看起来像是对gpu方法的前向函数调用。
这是我的CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.8)
project (hellocaffe)
if(ON)
if(NOT OpenCV_FOUND)
set(Caffe_OpenCV_CONFIG_PATH "/usr/share/OpenCV")
if(Caffe_OpenCV_CONFIG_PATH)
get_filename_component(Caffe_OpenCV_CONFIG_PATH ${Caffe_OpenCV_CONFIG_PATH} ABSOLUTE)
if(EXISTS ${Caffe_OpenCV_CONFIG_PATH} AND NOT TARGET opencv_core)
message(STATUS "Caffe: using OpenCV config from ${Caffe_OpenCV_CONFIG_PATH}")
include(${Caffe_OpenCV_CONFIG_PATH}/OpenCVModules.cmake)
endif()
else()
find_package(OpenCV REQUIRED)
endif()
unset(Caffe_OpenCV_CONFIG_PATH)
ENDIF() ENDIF()
get_filename_component(Caffe_CMAKE_DIR" / home / nikfio / bin / caffe / cmake" PATH)
设置(Caffe_INCLUDE_DIRS / home / nikfio / bin / caffe / include) 列表(APPEND Caffe_INCLUDE_DIRS" / usr / include") list(APPEND Caffe_INCLUDE_DIRS" /usr/local/cuda-9.0/include") list(APPEND Caffe_INCLUDE_DIRS" / usr / include / opencv") 列表(APPEND Caffe_INCLUDE_DIRS" / usr / include / atlas") 列表(APPEND Caffe_INCLUDE_DIRS" / home / nikfio / bin / caffe / build / src /")
include_directories($ {Caffe_INCLUDE_DIRS})
set(Caffe_DEFINITIONS" -DUSE_OPENCV; -DUSE_LMDB; -DUSE_LEVELDB")
设置(CAFFE_DIR / home / nikfio / bin / caffe)
set(LIBRARY -L $ {CAFFE_DIR} / build / lib -L / usr / local / Cellar / opencv / 2.4.11_1 / lib / -lglog -lprotobuf -lpython2.7 -lcaffe -lm -lpthread -lopencv_core - lopencv_imgproc -lopencv_highgui)
add_executable(ex_logreg_mnist ex_logreg_mnist.cpp)
target_link_libraries(ex_logreg_mnist $ {LIBRARY} -lboost_system)
有人知道为什么或有更好的解决方案吗?
此致
答案 0 :(得分:1)
在您的定义行中添加以下内容:
set(Caffe_DEFINITIONS "-DUSE_OPENCV;-DUSE_LMDB;-DUSE_LEVELDB;-DCPU_ONLY=1")
CPU_ONLY=1
应正确评论所有GPU代码。