CPU_ONLY构建:编译函数 Forward() 会给出错误"undefined reference..."
CPU_ONLY build: compiling the function Forward() gives error "undefined reference..."
我是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::设置模式(Caffe::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)
FIND_PAGE(咖啡)
设置(Caffe_INCLUDE_DIRS/home/nikfio/bin/Caffe/INCLUDE)列表(APPEND Caffe_INCLUDE_DIRS"/usr/INCLUDE")列表(APPEND Caffe_INCLUDE_DIRS"/usr/local/cuda-9.0/INCLUDE")列表(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})
定义
设置(Caffe_DINITINGS"-DUSE_OPENCV;-DUSE_LMDB;-DUSE_LEVELDB")
设置(CAFFE_DIR/home/nikfio/bin/CAFFE)
设置(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_loggre_mnist.cpp)
target_link_libraries(ex_logreg_mnist${LIBRARY}-lhostrongystem)
有人知道为什么或者有更好的解决方案吗?
问候
在定义行中添加以下内容:
set(Caffe_DEFINITIONS "-DUSE_OPENCV;-DUSE_LMDB;-DUSE_LEVELDB;-DCPU_ONLY=1")
CPU_ONLY=1
应正确注释掉所有GPU代码。
- 分段错误当我试图运行程序时出错
- .h 和.cpp文件分离时出错,但仅使用 .h 文件时没有错误.我做错了什么?
- 创建 OpenCV 非自由版本 v4.3 时出错,可折叠.cpp错误 C2039、2605
- 制作时出错,C++"db.c:2127:错误:在"||"标记之前应使用";"
- C++语法错误,编译器不会警告或 int v = func(&v) 出错;
- 在VS2015中访问类成员时运行时错误,但在Linux上未访问时出错
- 如何更改路径以修复错误"./main:加载共享库 libmkl_core.so 时出错?
- 为什么在定义类之前声明类的对象会在友元类中给出错误,而在友元函数中不会出错
- 安装 mply 库时出错.致命错误:gsl/gsl_sf.h:没有这样的文件或目录
- Rcpp/C++/R:比较日期时间矢量与日期时间时出错(错误:"运算符>"的不明确重载)
- 编译特征程序时出错:错误:'seq'不是'Eigen'的成员
- 可能的 GCC 链接器错误会导致将弱符号和局部符号链接在一起时出错
- 非标准语法;使用 '&' 创建指向成员的指针错误,将成员函数分配给向量时出错
- 运算符重载时出错(错误:"运算符<<不匹配(操作数类型为"std::basic_ostream<char>"和"const char [2]")
- 编译类 C++ 中的线程时出错(错误 xthread)
- 加载GLEW库时出错(错误LNK2001)
- 通过函数指针调用函数时出错(错误C2064)
- 编译core.obj时出错:错误LNK2001:未解析的外部符号_harmony_core_init
- 链接c++静态库与android ndk时出错(错误:无法识别文件格式)
- 使用GCC编译游戏时出错.(错误:将"Screen"的含义从"class Screen&q