使用Nvidia Jetson TX1,在新的C++工程中调用caffe

来源:互联网 发布:孪生素数c语言 编辑:程序博客网 时间:2024/06/04 18:58

使用Nvidia Jetson TX1,在新的C++工程中调用caffe

最近在英伟达的嵌入式平台下做一些任务,需要在一个现有的工程中调用caffe,这里简单记录一下中途遇到的一些问题和相应的配置方法

-caffe安装
首先,保证开发板上已经配置好caffe,此处caffe配置过程暂时省略,我的开发板操作系统是ubuntu的,配置过程基本没遇到什么麻烦。有一点需要提一下,在编译caffe过程中,遇到一个问题:

src/caffe/CMakeFiles/caffe.dir/build.make:650: recipe for target 'src/caffe/CMakeFiles/caffe.dir/util/gpu_memory.cpp.o' failed

这应该是平台问题,根据https://devtalk.nvidia.com/default/topic/976063/jetson-tx1/the-problem-with-the-assembly-of-caffe-0-15-on-%20jetsontx1/中提到的方法修改$CAFFE_ROOT/3rdparty/cub/host/mutex.cuh文件,利用下面第二行代码替换掉第一行代码,问题解决。

line124: --- #ifndef __arm__line124: +++ #if !defined(__arm__) && !defined(__aarch64__)

-新工程中调用caffe
由于我使用的是cmake,因此要调用caffe,我需要修改cmakelist.txt文件,对于原工程的部分基本不需要做什么修改,但是为了让程序找到caffe,需要添加以下几行代码:

set(Caffe_DIR "/home/ubuntu/caffe/build")find_package(Caffe REQUIRED)set(Caffe_INCLUDE_DIR /home/ubuntu/caffe/include)set(Caffe_SRC_DIR /home/ubuntu/caffe/src)include_directories(${Caffe_INCLUDE_DIR} /usr/local/include /usr/local/cuda-8.0/targets/aarch64-linux/include /home/ubuntu/caffe/build/include/)

后面的include_directories如果不添加,编译的过程中会提示找不到caffe或者cublas相关的一些头文件。

至此配置基本完成,配置一下依赖项:

target_link_libraries(yourproject yourprojectlib ${OpenCV_LIBS} ${Caffe_LIBS} /usr/lib/aarch64-linux-gnu/libboost_system.so)

如果不添加/usr/lib/aarch64-linux-gnu/libboost_system.so,会出现如下错误:

undefined reference to `boost::system::generic_category()'undefined reference to `boost::system::generic_category()'undefined reference to `boost::system::system_category()'

至此,所有配置工作完成,编译即可。

0 0
原创粉丝点击